Reply to Re: select form entries from a mysql table, is it possible?

Your name:

Reply:


Posted by Geoff Berrow on 10/14/05 20:43

I noticed that Message-ID:
<434fe092$0$13347$4fafbaef@reader2.news.tin.it> from none
<""neri\"@(none)"> contained the following:

>Let's say i want a <form><select> where each option value is taken
>straight from a mysql table.
>
>I have table "letters" (a,b,c,...) and I want the select options to be
>a,b,c...
>
>Can I do these? And how?
>Thanks,

<?php
$sql= "SELECT DISTINCT column FROM `table`";
$result=mysql_query($sql) or die("could not query database");
print"<select name='select'>\n<option>Select option</option>\n";
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$_POST['select']){
$selected=" selected";
}
else{
$selected="";
}
print"<option$selected>".$myrow[0]."</option>\n";
}
print"</select>\n";
?>
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация