0

i am try to create a drop down cms menu in my Website http://4your.co.in/demo2/. Problem is i have used a while loop to show main menu and another while loop to show submenu . Main menu is working but sub menu show online one record . My Code Is .

<?php
include 'config.php';
$page="";
$sql="select * from cms where sub_page='$page' order by pid";
$result = mysql_query($sql);
echo mysql_error();
while($row = mysql_fetch_row($result))
 {
echo "<li class='pureCssMenui0'><a class='pureCssMenui0' href=content.php?a=$row[0]><span>$row[1]</span></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->"; 
$spage=$row[1];
$sq="SELECT * 
FROM cms
WHERE sub_page =  '$spage'
ORDER BY pid ";
$res = mysql_query($sq);
echo mysql_error();
while($dropdown = mysql_fetch_row($res))
 {
  echo "<ul class='pureCssMenum'><li class='pureCssMenui0'><a class='pureCssMenui' href=content.php?a=$dropdown[0]>$dropdown[1]</a></li></ul><!--[if lte IE 6]></td></tr></table></a><![endif]--></li>";
 }
 }
?>

Please Help ME Friends

4
Contributors
6
Replies
8
Views
7 Years
Discussion Span
Last Post by dev.vini
0

Does it output only one record, or do you see only one record, while there are more in your pagesource. The former would mean your query returns only one result, the latter would mean your html/css is probably incorrect.

0

echo $sq; and run that query in sql window.
See what you are getting for each page.

Is In SQL Window In PHPMYADMIN i Am getting Right Result Bu Not In THE Font OF MY Site

0

get it..
Here problem is with UL LI.
Try this:

<?php
include 'config.php';
$page="";
$sql="select * from cms where sub_page='$page' order by pid";
$result = mysql_query($sql);
echo mysql_error();
while($row = mysql_fetch_row($result))
 {
echo "<li class='pureCssMenui0'><a class='pureCssMenui0' href=content.php?a=$row[0]><span>$row[1]</span></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->"; 
$spage=$row[1];
$sq="SELECT * 
FROM cms
WHERE sub_page =  '$spage'
ORDER BY pid ";
$res = mysql_query($sq);
echo mysql_error();
echo "<ul class='pureCssMenum'>";
while($dropdown = mysql_fetch_row($res))
 {
  echo "<li class='pureCssMenui0'><a class='pureCssMenui' href=content.php?a=$dropdown[0]>$dropdown[1]</a></li>";
 }
 echo "</ul>";
 }
?>
0

Thanks Friend : vibhadevit


get it..
Here problem is with UL LI.
Try this:

<?php
include 'config.php';
$page="";
$sql="select * from cms where sub_page='$page' order by pid";
$result = mysql_query($sql);
echo mysql_error();
while($row = mysql_fetch_row($result))
 {
echo "<li class='pureCssMenui0'><a class='pureCssMenui0' href=content.php?a=$row[0]><span>$row[1]</span></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->"; 
$spage=$row[1];
$sq="SELECT * 
FROM cms
WHERE sub_page =  '$spage'
ORDER BY pid ";
$res = mysql_query($sq);
echo mysql_error();
echo "<ul class='pureCssMenum'>";
while($dropdown = mysql_fetch_row($res))
 {
  echo "<li class='pureCssMenui0'><a class='pureCssMenui' href=content.php?a=$dropdown[0]>$dropdown[1]</a></li>";
 }
 echo "</ul>";
 }
?>
0

how can we print the whole images of database in a single page with the help of while loop pls telll me

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.