Jump to content

help with simple script


mike16889

Recommended Posts

im build a script to display a simple menu that is stored in a database. Here's the code:

 

<link href="../FP_Themes/FP_Defualt/style.css" rel="stylesheet" type="text/css" />
<?php 
include('../FP_config.inc.php');
mysql_connect($FP_dbserver,$FP_username,$FP_password);
@mysql_select_db(fpmm0_3) or die( "Unable to select database");
$query="SELECT * FROM fp_menu";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo '<table border="0" width=198>';

$i=0;
while ($i < $num) {

$mtitle=mysql_result($result,$i,"title");
$murl=mysql_result($result,$i,"url");
$mHS=mysql_result($result,$i,"HS");

echo '
<tr>
	<td width="100%"><a href="$murl" class="menulink" class=&{ns4class};>$mtitle</a></td>
</tr>';

$i++;
}
echo '
</table>';
?>

 

but for some reason its not printing the values of the veriables just the veriable names eg:

<link href="../FP_Themes/FP_Defualt/style.css" rel="stylesheet" type="text/css" />
<table border="0" width=198>
<tr>
	<td width="100%"><a href="$murl" class="menulink" class=&{ns4class};>$mtitle</a></td>
</tr>
</table>

 

can someone please help. I'm only new to PHP and am not sure what i have done wrong. it's probably just somthing simple that i'v over looked...

Link to comment
Share on other sites

Did you try:

 

<link href="../FP_Themes/FP_Defualt/style.css" rel="stylesheet" type="text/css" />
<table border="0" width=198>
<tr>
	<td width="100%"><a href=$murl class="menulink" class=&{ns4class};>$mtitle</a></td>
</tr>
</table>

 

?

 

Sorry i'm not that experienced at PHP as well, but just trying to help ;)

 

Edit:

Oh also try to remove

mysql_close();

It might solve it...

Link to comment
Share on other sites

echo '
<tr>
	<td width="100%"><a href="$murl" class="menulink" class=&{ns4class};>$mtitle</a></td>
</tr>';

instread of this try

while ($i < $num) {

$mtitle=mysql_result($result,$i,"title");
$murl=mysql_result($result,$i,"url");
$mHS=mysql_result($result,$i,"HS");

?>
<tr>
	<td width="100%"><a href=<?php echo $mur; ?> class="menulink" class=&{ns4class};><?php echo $mtitle; ?></a></td>
</tr>
<?php
$i++;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.