How to change the layout of my php?
Posted: Tue Jul 13, 2004 7:28 am
I have developed a testimonials script and having trouble changing the way the information is displayed. I can get it to display fine, I just can't get it to go where I want it to. I am very new in my php.
If you look at the way it works you can see what I mean. Go here http://lsscripts.com/testimonials/admin/show.php If you click on the add testimonial and generate code it will show at the bottom of the table that is already there. So if I have more testimonials it will be way at the bottom. What I am wanting is for it to replace the table. Like its a new page so it's not all bunched together. This is all working with in one show.php file.
Here is the code I am working with;
If you look at the way it works you can see what I mean. Go here http://lsscripts.com/testimonials/admin/show.php If you click on the add testimonial and generate code it will show at the bottom of the table that is already there. So if I have more testimonials it will be way at the bottom. What I am wanting is for it to replace the table. Like its a new page so it's not all bunched together. This is all working with in one show.php file.
Here is the code I am working with;
Code: Select all
<?
$status = (!empty($_GET['status']) ? $_GET['status'] : '%');
include "../inc/config.php";
$displaymessage =1;
switch($action) {
case "store":
db();
$link_display=$HTTP_POST_VARS['link_display'];
mysql_query("INSERT INTO ls_testimonials SET link_display='$link_display', client_id='$client_id', email='$email', company='$company', testimonials='$testimonials'");
db_close();
$displaymessage =2;
break;
case "code":
$displaymessage =3;
break;
case "home":
$displaymessage =0;
$pagecontent.="<table width=44% border=1 cellpadding=2 cellspacing=3 bordercolor=#000000 bgcolor=#CCCCCC>
<tr bordercolor=#CCCCCC>
<td width=49%>Welcome to the Control Panel of LS Testimonials.</td>
</tr>
</table>";
break;
case "add":
$displaymessage =5;
db();
break;
case "approve":
$displaymessage =6;
db();
mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
db_close();
break;
case "hold":
$displaymessage =7;
db();
mysql_query("UPDATE ls_testimonials SET approved='h' WHERE id=$id");
db_close();
break;
case "delete":
$displaymessage =8;
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=show.php?action=add>Add Testimonials</a><br>
<a href=show.php?status=n>New Testimonials</a><br>
<a href=show.php?status=h>On Hold Testimonials</a><br>
<a href=show.php?status=y>Active Testimonials</a><br>
<a href=show.php?action=code>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 == 2)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td>Added to database.</td>";
}
else if ($displaymessage ==3)
{
$pagecontent.="<table width=500 border=1 cellpadding=2 cellspacing=3 bordercolor=#000000 bgcolor=#CCCCCC>
<tr bordercolor=#CCCCCC>
<td width=49%>Implement random page</td>
<td width=51%><textarea style=width=300; border: 1; rows=1>This will be used in the future, for generating random testimonials code. For now look in the document folder.</textarea></td>
</tr>
</table>";
}
else if ($displaymessage ==5)
{
$pagecontent.="<table width=60 border=0 cellspacing=3 cellpadding=0>
<tr>
<td align=center>
<table width=500 border=1 cellpadding=2 cellspacing=3 bordercolor=#000000 bgcolor=#CCCCCC>
<tr bordercolor=#CCCCCC>
<td width=27%><font size=2><strong>Client ID# :</strong></font></td>
<td width=73%><form method=post><input name=client_id> (numbers only)</td>
</tr>
<tr bordercolor=#CCCCCC>
<td><font size=2><strong>Displayed Link</strong></font></td>
<td> <input name=link_display> (displayed over website link)</td>
</tr>
<tr bordercolor=#CCCCCC>
<td><font size=2><strong>Website</strong></font></td>
<td> <input name=company value=http://> (company website)</td>
</tr>
<tr bordercolor=#CCCCCC>
<td><font size=2><strong>Email</strong></font></td>
<td> <input name=email> (must be a valid e-mail)</td>
</tr>
<tr bordercolor=#CCCCCC>
<td><font size=2><strong>Testimonial :</strong></font></td>
<td> <textarea name=testimonials rows=7 cols=40></textarea></td>
</tr>
<tr bordercolor=#CCCCCC>
<td> </td>
<td><input type=hidden name=action value=store>
<input type=submit value='Submit'></td>
</tr>
</table>
</td>
</tr>
</table>";
}
else if ($displaymessage ==6)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td>Item {$id} Approved</td>";
}
else if ($displaymessage ==7)
{
$pagecontent.="</table></td>
</tr>
<tr>
<td></td>
<td>Item {$id} On Hold</td>";
}
else if ($displaymessage ==8)
{
$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>