Hi all,
Now, I have been creating a web site which is about cell phones, so I want to add some good properties to the site. I did some, but I could not create a drop down list whose each element comes from a database. When a person enter the site, he or she must see a drop down list and choose one choice, and then this choice must go to the database and check whether the choice is available in tha database. If it is available, the page must give a new page which includes the properties of the phone that takes all the information from the database.
I can use the database, but I could not write the code with PHP.
Thank you for now...
Create a Drop Down List with PHP
Moderator: General Moderators
-
mustafamisir
- Forum Newbie
- Posts: 23
- Joined: Wed Jun 22, 2005 1:00 pm
- Contact:
sure exactly what you mean I am not:
if create a dropdown list from database is all you need the followig you should try:
if create a dropdown list from database is all you need the followig you should try:
Code: Select all
$result = mysql_query("select id, phonename from phones")
or die(mysql_error());
$stuff = "<select name=\"phone\">";
while($row = mysql_fetch_assoc($result)){
$stuff .= "<option value=\"".$row['id']."\">".$row['phonename']."</option>";
} // end while for result set
$stuff .= "</select>";
echo $stuff;-
mustafamisir
- Forum Newbie
- Posts: 23
- Joined: Wed Jun 22, 2005 1:00 pm
- Contact:
-
mustafamisir
- Forum Newbie
- Posts: 23
- Joined: Wed Jun 22, 2005 1:00 pm
- Contact: