Here is the code i am using
---------------
badlist.php - main script that list all records
---------------
Code: Select all
<? include('includes/badlist_header.inc.php'); ?>
<tr>
<td width=99 align=center bgcolor=#333333><b>
<font color=#FFFFFF>Name</font></b></td>
<td width=100 align=center bgcolor=#333333><b>
<font color=#FFFFFF>Phone #</font></b></td>
<td width=460 align=center bgcolor=#333333><b>
<font color=#FFFFFF>Notes</font></b></td>
<td width=103 align=center bgcolor=#333333><b>
<font color=#FFFFFF>Last Updated</font></b></td>
</tr>
<?
include('includes/settings.inc.php');
$result = mysql_query("SELECT * FROM badlist",$db);
while ($info = mysql_fetch_array($result))
{
?>
<tr>
<td width=99 valign=top> <a href=badlist_addedit.php?id=<? echo "{$info['id']}"; ?>><? echo "{$info['name']}"; ?></a>
<a href=badlist_delete.php?id=<? echo "{$info['id']}"; ?>><font size=1 color=red><b>D</b></font></a>
</td>
<td width=100 valign=top><center><? echo "{$info['phone']}"; ?></center></td>
<td width=460 valign=top> <? echo "{$info['notes']}"; ?></td>
<td width=103 valign=top><center><? echo "{$info['last_update']}"; ?></center></td>
</tr>
<?
}
include('includes/badlist_footer.inc.php');
?>
<center><font size=1><? echo $copyright; ?></font></center>badlist_addedit.php - add new entry
-----------
Code: Select all
<?
include('includes/settings.inc.php');
if($submit)
{
$sql = "INSERT INTO badlist (name, phone, notes, last_update) VALUES ('$name','$phone','$notes','$last_update')";
$result = mysql_query($sql);
echo "Added to database.\n";
}
else if($update)
{
$sql = "UPDATE badlist SET name='$name',phone='$phone',notes='$notes',last_update='$last_update'";
$result = mysql_query($sql);
echo "Updated database.\n";
}
else if($id)
{
$result = mysql_query("SELECT * FROM badlist WHERE id=$id",$db);
$info = mysql_fetch_array($result);
?>
<? include('includes/badlist_header.inc.php'); ?>
<form method=post action=<? echo $PHP_SELF?>>
<input type=hidden name=id value=<? echo $info["id"]?>>
Name: <input type=text name=name value=<? echo "{$info['name']}"?>><br>
Phone: <input type=text name=phone value=<? echo "{$info['phone']}"?>><br>
Notes:<br>
<textarea cols=40 rows=4 name=notes><? echo "{$info['notes']}"?></textarea>
<br>
Last Updated: <? echo "{$info['last_update']}"?>
<input type=hidden name=last_update value=<? include('includes/date.inc.php'); ?><br>
<input type=submit name=update value="Update Listing"></form>
<? include('includes/badlist_footer.inc.php'); ?>
<center><? echo $copyright; ?></center>
<?
}
else
{
?>
<? include('includes/badlist_header.inc.php'); ?>
<form method=post action=<? echo $PHP_SELF?>>
Name: <input type=text name=name><br>
Phone #: <input type=text name=phone><br>
Notes:<br>
<textarea cols=40 rows=4 name=notes></textarea><br>
<input type=hidden name=last_update value=<? include('includes/date.inc.php'); ?>>
<input type=submit name=submit value="Add information">
</form>
<? include('includes/badlist_footer.inc.php'); ?>
<center><font size=1><? echo $copyright; ?></font></center>
<?
}
?>If one of you guys can help me figure out what wrong with this script, I would greatly appriciated it.
Thank you in advance!