Jump to content


Photo

Dropdown box not showing options...


  • Please log in to reply
3 replies to this topic

#1 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 09 July 2006 - 10:20 AM

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.

<?php

include('../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>


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 July 2006 - 10:26 AM

if(mysql_num_rows($result2) < 1)
{
to this

if(mysql_num_rows($result2) > 0)
{


and this

<form action="add_forum.php" method="POST">

to this

<form action=" " method="POST">

just try ok
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 09 July 2006 - 10:29 AM

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.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 July 2006 - 10:34 AM

      echo "<option value=\"". $row['id'] ."\">". $row['title'] ."</option> \n";

what this mean above exsplain

id what? NULL with the title of NULL

this 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";
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users