bubbles Posted October 10, 2013 Report Posted October 10, 2013 (edited) Vreau sa fac generez in while coduri PHP fara ca ele sa fie rulate.<?php $x=1; while($x<=5) { echo"<td><code><?php if (in_array(".$x.", $numere_tura_1)) {echo "<span class=\"num\">".$x."</span>";} ?></code></td>"; $x++; } ?>Unde gresesc ? Merci.Practiv vreau sa-mi afiseze :<td><?php if (in_array(1, $numere_tura_1)) {echo "<span class=\"num\">1</span>";} ?></td><td><?php if (in_array(2, $numere_tura_1)) {echo "<span class=\"num\">2</span>";} ?></td><td><?php if (in_array(3, $numere_tura_1)) {echo "<span class=\"num\">3</span>";} ?></td><td><?php if (in_array(4, $numere_tura_1)) {echo "<span class=\"num\">4</span>";} ?></td><td><?php if (in_array(5, $numere_tura_1)) {echo "<span class=\"num\">5</span>";} ?></td> Edited October 10, 2013 by bubbles Quote
eusimplu Posted October 10, 2013 Report Posted October 10, 2013 Eu unul nu am inteles ce vrei sa spui. Quote
EAdrian Posted October 10, 2013 Report Posted October 10, 2013 (edited) În primul rând nu cred c? în?elege nimeni ce vrei s? spui, în al 2-lea rând variabila $numere_tura_1 nu este definit?.LE: în loc de < pui < Edited October 10, 2013 by EAdrian Quote
eusimplu Posted October 10, 2013 Report Posted October 10, 2013 @bubbles: Foloseste entitati HTML. Quote
aggroxx Posted October 10, 2013 Report Posted October 10, 2013 while(10<=5) si nu o sa-ti ruleze niciodata ce ai in while ) Quote
bubbles Posted October 10, 2013 Author Report Posted October 10, 2013 (edited) @EAdrian - variabila $numere_tura_1 este definita, dar nu am postat-o, pe mine ma intereseaza doar partea asta :<?php if (in_array($x, $numere_tura_1)) {echo "<span class=\"num\">$x</span>";} ?>Pe care vreau sa o generez(html) de cate ori vreau, insa variabila x sa fie consecutiva.@eusimplu - am incercat, insa nu-mi mai afiseaza $x atunci.Gresesc undeva la concatenare cred.@aggroxx - care e scopul postarii tale ? Edited October 10, 2013 by bubbles Quote
pedala1 Posted October 10, 2013 Report Posted October 10, 2013 (edited) echo htmlentities("<td><code><?php if (in_array(".$x.", ".$numere_tura_1.")) {echo \"<span class=\"num\">".$x."</span>\";} ?></code></td>");sauecho "<td><code><?php if (in_array(".$x.", ".$numere_tura_1.")) {echo \"<span class=\"num\">".$x."</span>\";} ?></code></td>";daca vrei sa functioneze <td><code> </code></td> : echo "<td><code>".htmlentities("<?php if (in_array(".$x.", ".$numere_tura_1.")) {echo \"<span class=\"num\">".$x."</span>\";} ?>")."</code></td>";(cred k asta vroiai ) Edited October 10, 2013 by pedala1 1 Quote
EAdrian Posted October 10, 2013 Report Posted October 10, 2013 (edited) @EAdrian - variabila $numere_tura_1 este definita, dar nu am postat-o, pe mine ma intereseaza doar partea asta :Când postezi o problem?, posteaz-o complet.. c? noi nu suntem nevoi?i s?-?i refacem ?ie codulhttp://pastebin.com/hC9v2A7nOutput:<td><code><?php if (in_array(1), $numere_tura_1)){ echo "1" } ?></td></code><td><code><?php if (in_array(2), $numere_tura_1)){ echo "2" } ?></td></code><td><code><?php if (in_array(3), $numere_tura_1)){ echo "3" } ?></td></code><td><code><?php if (in_array(4), $numere_tura_1)){ echo "4" } ?></td></code><td><code><?php if (in_array(5), $numere_tura_1)){ echo "5" } ?></td></code>Better solution: https://rstforums.com/forum/76312-php-code-while.rst#post491408 Edited October 10, 2013 by EAdrian Quote
bubbles Posted October 10, 2013 Author Report Posted October 10, 2013 Merci, am rezolvat.@EAdrian - nu inteleg "s?-?i refacem ?ie codul", am explicat clar ca nu stiam sa generez cod php intr-un while fara ca el sa se ruleze si sa fie doar afisat ca si HTML.In fine, va multumesc. Quote