Scrip php in <option>

Ai o întrebare legată de PHP? Incercăm să îi găsim soluţie. Sau poate doar vrei să publici un cod interesant.

Moderatori: Zamolxe, Moderatori

mika
PHPRomania Supporter
Mesaje: 11
Membru din: Sâm Mar 11, 2006 3:32 pm

Scrip php in <option>

Mesajde mika » Sâm Mar 25, 2006 11:28 pm

Salutare.
Cum poti sa introduci in comanda de html <select> </select> valorile dintr-o baza de date mysql astfel incat fiecare valoare din coloana de tabel sa reprezinte o pereche de <option> </option>.



Avatar utilizator
kleampa
Senior Member
Mesaje: 2774
Membru din: Dum Iul 10, 2005 2:12 pm
Localitate: Bucuresti
Contact:

Mesajde kleampa » Sâm Mar 25, 2006 11:43 pm

[php]echo '<select name="id_story">';
$sql = "SELECT * FROM story ORDER BY id_story DESC";
$resursa = mysql_query($sql);
while($story=mysql_fetch_object($resursa))
{
echo '<option value="'.$story->id_story.'">'.$story->id_story.'</option>';
}
echo '</select>';[/php]

modifica si tu cum ai nevoie

mika
PHPRomania Supporter
Mesaje: 11
Membru din: Sâm Mar 11, 2006 3:32 pm

Mesajde mika » Sâm Mar 25, 2006 11:54 pm

Multumesc mult de tot , functioneaza de minune.
Mersi mult.


Înapoi la “Cod PHP”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 15 vizitatori