Working off of this code here, I am able to list the categories and the appropriate subjects under them. I now wanted to make that list of subjects appear as a drop down menu list, but I can not seem to get it to work correctly. It either displays all of the subjects as an individual option and not in a group, or it doesn't display it at all. Here is the code I am using without being modified to display as a dropdown menu:
$sql="select corporate_articles.articles_id, ".
" corporate_articles.articles_number as number, ".
" corporate_articles_sections.articles_data as title ".
" from corporate_articles left join corporate_articles_sections".
" on corporate_articles.articles_id=corporate_articles_sections.articles_id";
$result=mysql_query($sql)
or die ("Sql prob:".$sql."<p>".
mysql_errno().": ".mysql_error());
$i=-1;
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)){
if ($row['articles_id']<>$i){
echo $row['number']."<br>";
$i=$row['articles_id'];
}
if ($row['title]){
echo stripslashes($row['title'])."<br>";
}
}
I was trying something like this, but it will not work out.
$sql="select corporate_articles.articles_id, ".
" corporate_articles.articles_number as number, ".
" corporate_articles_sections.articles_data as title ".
" from corporate_articles left join corporate_articles_sections".
" on corporate_articles.articles_id=corporate_articles_sections.articles_id";
$result=mysql_query($sql)
or die ("Sql prob:".$sql."<p>".
mysql_errno().": ".mysql_error());
$i=-1;
while ($row=mysql_fetch_array($result, MYSQL_ASSOC)){
if ($row['articles_id']<>$i){
echo $row['number']."<br>";
echo "<SELECT NAME=\"Articles\">\n"; // Start dropdown list under the category
$i=$row['articles_id'];
}
if ($row['title']){
$title=stripslashes($row['title']);
echo "<OPTION VALUE=\"$title\">$title</OPTION>\n";
}
echo"</SELECT>\n"; // It's just not displaying correctly.
}
Please help me figure out what I am doing wrong, been trying different ways and just can't seem to figure it out 🙁
Thanks