Forums Archive Index > SmartMenus 5 > Dynamic menu item

Author: stefane321

Date: 15 Feb 2005 4:29 pm

I want to execute an php query to feel one of my menu but I dont know how to introduce it in s_array.php (I saved s_array.js to s_array.php)

Here is my PHP query:

Code:
s_add(
{N:'activites',LV:1,MinW:130,T:110,L:420,P:false,S:s_CSSTop},
[
<?php
include("config.php");
$table="activites";
mysql_connect($host,$login,$password);
mysql_select_db($db);
$sql = "select * from $table order by ord_affiche ASC ";
if($result = mysql_query($sql))
{
// parcours des résultats
while($row = mysql_fetch_array($result) )
{
   
echo {U:' activites_details.php?id='.$row["id"].'', T: ''.StripSlashes($row["name"]).''};
   
}

}
?>
]
);


Can you please help me?


Author: smartmenus
Subject: Re: Dynamic menu item

Date: 16 Feb 2005 3:07 pm

Your syntax is not correct. Replace this:

Code:

if($result = mysql_query($sql))
{
// parcours des résultats
while($row = mysql_fetch_array($result) )
{
   
echo {U:' activites_details.php?id='.$row["id"].'', T: ''.StripSlashes($row["name"]).''};
   
}

}


with this (for instance):

Code:
if($result = mysql_query($sql))
{
// parcours des resultats

$output="";

   while($row = mysql_fetch_array($result))
      $output.="{U:'activites_details.php?id=".$row["id"]."',T:'".StripSlashes($row["name"])."'},";

$output=substr($output,0,-1); // removes the last comma

echo $output;

}


Author: stefane321
Subject: It does not work any more!

Date: 17 Feb 2005 11:44 am

Thanks but It does not work any more!


Author: smartmenus

Date: 17 Feb 2005 1:49 pm

stefane321, I would suggest you to let some experienced PHP programmer do the job for you. Because you obviously have some difficulties and it will probably take you quite some time to do it on your own.. :?