bassdog65 Posted August 5, 2009 Share Posted August 5, 2009 here is my code snippet: <div><b>Category Name:</b> <p><input type="radio" name="category" value="existing" <?php if (isset($_POST['category']) && ($_POST['category'] == 'existing') ) echo ' checked="checked"'; ?>/> Existing => <select name="existing"><option>Select One</option> <?php $x = "SELECT category FROM artists"; $y = mysqli_query ($dbc, $x); if (mysqli_num_rows($y) > 0) { while ($row = mysqli_fetch_array ($y, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; if (isset($_POST['existing']) && ($_POST['existing'] == $row[0]) ) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } } else { echo '<option>Please add a new category.</option>'; } mysqli_close($dbc); ?> </select></p> <p><input type="radio" name="category" value="new" <?php if (isset($_POST['category']) && ($_POST['category'] == 'new') ) echo ' checked="checked"'; ?>/> New => <input type="text" name="category_name" size="20" maxlength="40" value="<?php if (isset($_POST['category_name'])) echo $_POST['category_name']; ?>" /></p> </div> Im trying to give the user the option of picking a category already in the database, or to make a new one. For some reason the result is not displaying in my dropdown when there are already categories in the database. When I run the mySQL query in phpMyAdmin it returns results. What am I missing? Link to comment https://forums.phpfreaks.com/topic/168976-mysql-query-not-pulling-into-html-properly/ Share on other sites More sharing options...
fenway Posted August 10, 2009 Share Posted August 10, 2009 Well, debug the result set from your query directly -- otherwise, it's a php logic error. Link to comment https://forums.phpfreaks.com/topic/168976-mysql-query-not-pulling-into-html-properly/#findComment-894761 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.