localhost Posted July 9, 2006 Share Posted July 9, 2006 This is supposed to show the categories' names so I can choose which category to put the forum in but its showing up blank! and Inserts cid as 0.[code=php:0]<?phpinclude('../connect.php');if(isset($_POST['submit']) && !empty($_POST['title'])){$title = $_POST['title'];$description = $_POST['description'];$cid = $_POST['cid'];$query = "INSERT INTO forums (`id`, `cid`, `title`, `description`) VALUES ('NULL', '$cid', '$title', '$description')";$result = mysql_query($query) or die(mysql_error());echo "Forum successfully added.";}$query2 = "SELECT id, title from categories ORDER BY title ASC";$result2 = mysql_query($query2) or die(mysql_error());if(mysql_num_rows($result2) < 1) {echo "Categories must first exist before forums. (Parents before children!)";}?><form action="add_forum.php" method="POST">Forum Title:<input type="text" name="title" /><br />Forum Description: <input type="text" name="description" /><Br />Parent Category: <select name="cid"><? while($row = mysql_fetch_array($result2)) { echo "<option value=\"". $row['id'] ."\">". $row['title'] ."</option> \n"; }?></select><br /><input type="submit" name="submit" value="Add" /></form>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14085-dropdown-box-not-showing-options/ Share on other sites More sharing options...
redarrow Posted July 9, 2006 Share Posted July 9, 2006 if(mysql_num_rows($result2) < 1) {to thisif(mysql_num_rows($result2) > 0) {and this<form action="add_forum.php" method="POST">to this<form action=" " method="POST">just try ok Quote Link to comment https://forums.phpfreaks.com/topic/14085-dropdown-box-not-showing-options/#findComment-55063 Share on other sites More sharing options...
localhost Posted July 9, 2006 Author Share Posted July 9, 2006 Both of those statements are horribly wrong man....if the number of rows is higher than 0, that means there are categories, meaning it shouldn't display the message.Also, using "" and add_forum.php do the exact same thing, I've used both. Quote Link to comment https://forums.phpfreaks.com/topic/14085-dropdown-box-not-showing-options/#findComment-55064 Share on other sites More sharing options...
redarrow Posted July 9, 2006 Share Posted July 9, 2006 echo "<option value=\"". $row['id'] ."\">". $row['title'] ."</option> \n";what this mean above exsplainid what? NULL with the title of NULLthis looks better$query2 = "SELECT categories.id, categories.title from categories WHERE id='NULL' ORDER BY title ASC";and echo "<option value=\"". $row['title'] ."\">". $row['title'] ."</option> \n"; Quote Link to comment https://forums.phpfreaks.com/topic/14085-dropdown-box-not-showing-options/#findComment-55067 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.