I want my drop down list to retrieve/display data from database using php and mysql.. could u check it plz?
-
i still can not display the data from mydatabase to the drop down list.... in my table that i named it as category have two field/column that are caID and caName.. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("kbms", $con); $sql="SELECT caName FROM category"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["caName"]; $thing=$id; $options.="<OPTION VALUE=\"$id\">".$thing.'</option>'; } ?> <SELECT name= caName id="caName"> <OPTION VALUE=0>Choose <?=$options?></OPTION> </SELECT>
-
Answer:
<?php ?> <!--beginning of the HTML page, up to the dropdown--> <?php $con = mysql_connect("localhost","root",""); //rest of your php code <?php while ($row=mysql_fetch_array($result)) { ?> <SELECT name= caName id="caName"> <OPTION VALUE=?<php echo $id; ?>><?php echo $thing; ?></option> <?php } ?> </select> I did this off the top of my head, so there may be some typos.
Me M at Yahoo! Answers Visit the source
Related Q & A:
- How To Build Business Directory Using Php Mysql?Best solution by Stack Overflow
- How to retrieve data from table using its key?Best solution by msdn.microsoft.com
- How to store an image in database using MySQL?Best solution by stackoverflow.com
- How to display HTML data from database?Best solution by Stack Overflow
- Can some plz help, i want to get an 11-15 oyster photo card and i dont know how to post it?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.