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

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.

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

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

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>";
 }
?>

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>";
 }
?>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.