SourceTec Software

It is currently Wed Apr 23, 2014 9:23 pm

All times are UTC + 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Dec 10, 2009 10:57 pm 
Offline
Member

Joined: Mon Dec 11, 2006 9:21 am
Posts: 17
Hi,

I have the menu fully working against a mysql database and it is great, I love it!

I have one small issue. In order to control the order to sequence of the menu items I have a field in the table called menu_order.

$query = "select * from menu where menu_id_parent=0 AND menu_visible='Yes' Order By menu_order";

This works fine for sorting the top level menu items but doesn't affect the order of submenu items.

I use only one table and reference the same table with the submenu script:

$queryPro = "select * from menu where menu_visible='Yes' AND menu_id_parent=".$rowCat["menu_id"];

In a perfect world, I would just make this line:

$queryPro = "select * from menu where menu_visible='Yes' AND menu_id_parent=".$rowCat["menu_id"] Order By menu_order;

The problem is that the 'Order by' code falls outside the " and I think that this is breaking the sql statement because the menu no longer shows. Is there a way to do what I am trying to achieve?

For reference purposes, my full script is below:

stm_bm(["menu501d",850,"/","blank.gif",0,"","",0,0,250,0,1000,1,0,0,"","",67108867,0,1,2,"default","hand","file:///C|/Documents%20and%20Settings/Pete/My%20Documents/Websites/Websites%20P%20-%20R/Povey.ca"],this);
stm_bp("p0",[0,4,0,0,0,0,0,0,100,"",-2,"",-2,50,0,0,"#999999","transparent","",0,0,0,"#000000"]);
<?
$dbhost = "localhost"; // DB Host name
$dbusername = "durabond"; // DB User
$dbpass = "1Durjan2"; // DB User password
$dbname = "durabond"; // DB Name
$query = "select * from menu where menu_id_parent=0 AND menu_visible='Yes' Order By menu_order";
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$resultCat = mysql_db_query($dbname, $query);
$numrowsCat = mysql_num_rows($resultCat);

for ($i = 0; $i < $numrowsCat; $i++)
{
$rowCat = mysql_fetch_array($resultCat);
$Caption = $rowCat["menu_name"];
$Link = $rowCat["menu_link"];
$Tip = $rowCat["menu_title"];
$Width = $rowCat["menu_width"]

?>
stm_ai("p0i0",[1,"<?=$Caption?>","","",-1,-1,0,"<?=$Link?>","_self","","<?=$Tip?>","","",0,0,0,"","",0,0,0,1,0,"#FFFFFF",1,"#FFD602",1,"","",3,3,0,0,"#E6EFF9","#000000","#FFFFFF","#c6c5bc","bold 11px Verdana","bold 11px Verdana",0,0],"<?=$Width?>",0);
stm_bpx("p1","p0",[1,4,0,0,4,3,0,0,75,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.60)",-2,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.60)",-2,50,2,5,"#999999","#678DB4","",3]);
<?
$queryPro = "select * from menu where menu_visible='Yes' AND menu_id_parent=".$rowCat["menu_id"];
$resultPro = mysql_db_query($dbname, $queryPro);
$numrowsPro = mysql_num_rows($resultPro);

for ($j = 0; $j<$numrowsPro; $j++)
{
$rowPro = mysql_fetch_array($resultPro);
$ProName = $rowPro["menu_name"];
$Link = $rowPro["menu_link"];
$Tip = $rowPro["menu_title"];
?>
stm_ai("p1i0",[1,"<?=$ProName?>","","",-1,-1,0,"<?=$Link?>","_self","","<?=$Tip?>","","",0,0,0,"","",0,0,0,0,1,"#678DB4",0,"#678DB4",0,"","",0,0,0,0,"#000000","#000000","#FFFFFF","#c6c5bc","bold 11px Verdana","bold 11px Verdana",0,0]);
stm_bpx("p2","p0",[1,2,0,0,4,3,0,0,75,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.60)",-2,"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=0.60)",-2,50,2,5,"#999999","#678DB4","",3]);
<?
$querySub = "select * from menu where menu_visible='Yes' AND menu_id_parent=".$rowPro["menu_id"];
$resultSub = mysql_db_query($dbname, $querySub);
$numrowsSub = mysql_num_rows($resultSub);

for ($k = 0; $k<$numrowsSub; $k++)
{
$rowSub = mysql_fetch_array($resultSub);
$SubName = $rowSub["menu_name"];
$Link = $rowSub["menu_link"];
$Tip = $rowSub["menu_title"];
?>
stm_ai("p2i0",[1,"<?=$SubName?>","","",-1,-1,0,"<?=$Link?>","_self","","<?=$Tip?>","","",0,0,0,"","",0,0,0,0,1,"#678DB4",0,"#678DB4",0,"","",0,0,0,0,"#000000","#000000","#FFFFFF","#c6c5bc","bold 11px Verdana","bold 11px Verdana",0,0]);
<?
}
?>
stm_ep();
<?
}
?>
stm_ep();
<?
}
?>
stm_ep();
stm_em();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 11, 2009 4:14 am 
Offline
Guru

Joined: Wed Jan 31, 2007 4:21 am
Posts: 1116
instead of using double quotes in $rowCat["menu_id"]; use single quotes like this $rowCat['menu_id'];


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 11, 2009 4:54 am 
Offline
Member

Joined: Mon Dec 11, 2006 9:21 am
Posts: 17
Hi,

Thanks for the tip. I have changed the double quotes to single quotes and it still functions

$queryPro = "select * from menu where menu_visible='Yes' AND menu_id_parent=".$rowCat['menu_id'];

but as soon as I modify the line in any way to try and fit in Order By menu_order, it breaks.

Any ideas on the correct syntax?
Thanks,
Pete


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 11, 2009 4:58 am 
Offline
Member

Joined: Mon Dec 11, 2006 9:21 am
Posts: 17
Solved it!

The correct syntax to add the sort code is:

$queryPro = "select * from menu where menu_visible='Yes' AND menu_id_parent=".$rowCat["menu_id"]." Order By menu_order";

Thanks for your help.
Pete


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 8 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group