Is there a better variable that I can use?
Posted: Wed Jul 14, 2004 9:37 pm
I am very new with php and I am useing at the moment the $pagecontent.= in my code to get info to display. Is there a better way to do this.
You can see a page of my code below:
You can see a page of my code below:
Code: Select all
<?
$status = (!empty($_GET['status']) ? $_GET['status'] : '%');
include "../inc/config.php";
$displaymessage =0;
switch($action) {
case "approve":
$displaymessage =1;
db();
mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
db_close();
break;
case "hold":
$displaymessage =2;
db();
mysql_query("UPDATE ls_testimonials SET approved='h' WHERE id=$id");
db_close();
break;
case "delete":
$displaymessage =3;
db();
mysql_query("DELETE FROM ls_testimonials WHERE id=$id");
db_close();
break;
default:
break;
}
db();
$query = "SELECT * FROM ls_testimonials WHERE approved LIKE '$status'";
$formdata_res=mysql_query($query) or die("query failed: " . mysql_error());
$pagecontent.="<table width=760 border=0 cellspacing=0 cellpadding=0
<tr>
<td width=150></td>
<td width=610> </td>
</tr>
<tr>
<td valign=top><table width=150 border=1 cellpadding=2 cellspacing=2 bordercolor=#FFFFFF>
<tr>
<td bordercolor=#000000 bgcolor=#CCCCCC><font size=2><b>Menu</b></font></td>
</tr>
<tr>
<td bordercolor=#000000><font size=2><p><a href=add.php>Add Testimonials</a><br>
<a href=manage.php?status=n>New Testimonials</a><br>
<a href=manage.php?status=h>On Hold Testimonials</a><br>
<a href=manage.php?status=y>Active Testimonials</a><br>
<a href=code.php>Generate Code</a></p></font></td>
</tr>
</table></td>";
$pagecontent.="<td valign=top>
<table width=99% border=1 align=center cellpadding=0 cellspacing=1 bordercolor=#FFFFFF>";
while ($formdata=mysql_fetch_object($formdata_res)) {
$client_id=htmlentities($formdata->client_id);
$link_display=htmlentities($formdata->link_display);
$email=htmlentities($formdata->email);
$company=htmlentities($formdata->company);
$testimonials=htmlentities($formdata->testimonials);
$pagecontent.="<td bordercolor=#999999 bgcolor=#F1F1F1><font size=2><b>Client ID#:</b></font>{$client_id}</td>
<td> </td>
<td> </td>
</tr>
<tr bordercolor=#666666>
<td width=203 bgcolor=#F1F1F1><font size=2><b>Display:</b></font></td>
<td width=203 bgcolor=#F1F1F1><font size=2><b>Email:</b></font></td>
<td width=203 bgcolor=#F1F1F1><font size=2><b>Website:</b></font></td></tr>
</tr>
<tr bordercolor=#666666>
<td width=203 bgcolor=#E9EDF0><font size=2>{$link_display}</font></td>
<td width=203 bgcolor=#E9EDF0><font size=2><a href='mailto:{$email}'>{$email}</a></font></td>
<td width=203 bgcolor=#E9EDF0><font size=2><a href='{$company}' target=new>{$company}</a></font></td>
</tr>
<tr bordercolor=#666666>
<td colspan=2><font size=2><b>Testimonial:</b></font><textarea style=width=300; border: 1; rows=1>{$testimonials}</textarea></td>
<td><center><a href='?id={$formdata->id}&action=approve'><img src=../inc/skins/default/images/approve.gif width=17 height=17 border=0 ALT=Approve></a>
<a href='?id={$formdata->id}&action=hold'><img src=../inc/skins/default/images/hold.gif width=17 height=17 border=0 ALT=Hold></a>
<a href='?id={$formdata->id}&action=delete'><img src=../inc/skins/default/images/delete.gif width=17 height=17 border=0 ALT=Delete></a> </center></td>
</tr>
<tr>
<td colspan=3> </td>
</tr>";
}
if ($displaymessage == 0)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td></td>";
}
else if ($displaymessage ==1)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td>Item {$id} Approved</td>";
}
else if ($displaymessage ==2)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td>Item {$id} On Hold</td>";
}
else if ($displaymessage ==3)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td>Item {$id} Deleted</td>";
}
//<!-- DO NOT REMOVE THIS CODE BELOW -->
$pagecontent.="</tr>
<tr>
<td> </td>
<td><div align=center>
<p> </p>
<p><font size=2>Powered by: <a href=http://www.lsscripts.com>LS Testimonials</a></font>
<br>
<font size=2>Ver. 1.0</font> </p>
</div></td>
</tr>
</table>";
//<!-- COPYRIGHT CODES END -->
db_close();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Approval Page</title>
</head>
<body><?=$pagecontent;?></body>
</html>