Hey guys.. i need your help. i'm failed to display data from mysql into dropdown list. well, this is my code.. connection.php index.php mainpost.php
I think it because <br> tag at echo "$Reflinks[ref_categories_id]==$Category[id]<br>\n"; Try your code without it.
This line echo "$Reflinks[ref_categories_id]==$Category[id]<br>\n"; PHP: should be generating an error, since there's no variable $Reflinks at that point. (And the syntax is all wrong - what are you trying to echo there? (The best you can get from it is true or false, but not that way.)
Remove this line all together echo "$Reflinks[ref_categories_id]==$Category[id]<br>\n"; PHP: And write any error messages your are getting.
See if this code works : <section id="mainpost"> <h3>Add or modify a listing</h3> <a href="#">Test Link</a> <form method="post" action="<?php $_SERVER['PHP_SELF']?>"> <label for="Category">Topic Category</label> <? $hostUrl="localhost"; $userName="root"; $password=""; $connectID=mysql_connect($hostUrl, $userName, $password) or die("sorry, can't connect to database"); mysql_select_db("database", $connectID) or die("unable to connect database"); mysql_close($connectID); print '<select name="category">'."\n"; print '<option value="none">Select a Catagory</option>'."\n"; $sql = 'SELECT * FROM ref_categories'; $Categories = mysql_query($sql,$connectID); while ($Category = mysql_fetch_assoc($Categories)) { //echo "$Reflinks[ref_categories_id]==$Category[id]<br>\n"; print '<option value="'.$Category['id'].'">'.$Category['category_name']."</option>\n"; } print '</select>'."<br />\n"; ?> <!-- topic_name --> <label for="topic_name">Topic Name</label> <input id="topic_name" name="topic_name" type="text" value="" /> <!-- topic_description --> <label for="topic_description">Topic Description</label> <textarea name="topic_description"></textarea> <!-- topic_url --> <label for="topic_url">Topic URL</label> <input id="topic_url" name="topic_url" type="text" value="" /> <input type="submit" name="submitted" value="submit" /> </form> </section> <!-- end mainpost --> Code (markup): I just commented the line causing error and replaced mysql_fetch_array by mysql_fetch_assoc.