Hi All,
I have struggled through this far with help from many of you so thanks. I am
stuck again. I am really new to this so don't be harsh :-)
There are a few problems. You can run the script here
http://www.pbrown.com/research/test1.php to see the formatting issues
Formatting Issues
1) Why do I get the extra '(' before the '(delete) link
2) Why does the 4th (and I think it is always the last rather than being
just the 4th) record always show below the Add Record link?
Editing Problem
1) When I actually select to delete a record it doesn't, I think it is
related to an 'id' issue but can't see where
2) When I click a link to edit it, it doesn't populate the form below...Why?
I know I am asking a lot. Thanks for any help indeed. If you are asking me
to put any code in to test please help me by being specific
Cheers
Paul
<html><style type="text/css">
<!--
body,td,th {
color: #CCCCCC;
}
body {
background-color: #000000;
}
a:link {
color: #CCCCCC;
}
a:visited {
color: #CCCCCC;
}
a:hover {
color: #CCCCCC;
}
a:active {
color: #CCCCCC;
}
..style1 {
font-size: x-small;
font-style: italic;
}
-->
</style>
<body>
<div align="left">
<p align="center"> <img src="/cpsheadersm.jpg " width="409"
height="110"></p>
<p> <?php
$db = mysql_connect(" localhost", "user", "password") ;
mysql_select_db ("reminders",$d b);
if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE research_main SET
date_event='$da te_event',info_ research='$info _research',medi um_name='$mediu m
_name',place_na me='$place_name ',date_invest=' $date_invest',v erified_event=' $
verified_event' ,closed_event=' $closed_event' WHERE id=$id";
} else {
$sql = "INSERT INTO research_main
(date_event,inf o_research,medi um_name,place_n ame,date_invest ,verified_event ,
closed_event) VALUES
('$date_event', '$info_research ','$medium_name ','$place_name' ,'$date_invest' ,
'$verified_even t','$closed_eve nt')";
}
// run SQL against the DB
$result = mysql_query($sq l);
echo "Record updated/edited!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM research_main WHERE id=$id";
$result = mysql_query($sq l);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$id) {
// print the list if there is not editing
$result = mysql_query("SE LECT * FROM research_main", $db);
while ($myrow = mysql_fetch_arr ay($result)) {
echo "<table border=2>\n";
echo "<tr><td> Investigation Date </td><td> Research Information
</tr><td> Mediums Name </tr><td> Location </tr><td> date being
Researched </tr>\n";
printf("(<a href=\"%s?id=%s \"><tr><td>% s</td><td> %s
</td><td>%s</td></tr></a> \n", $PHP_SELF, $myrow["id"],
$myrow["date_event "], $myrow["info_resea rch"], $myrow["medium_nam e"],
$myrow["place_name "], $myrow["date_inves t"], $myrow["verified_event "],
$myrow["closed_eve nt"]);
printf("<a href=\"%s?id=%s &delete=yes\">( DELETE)</a><br>", $PHP_SELF,
$myrow["id"]);
}
}
?>
</p>
</div>
<p> </p>
<P>
<a href="<?php echo $PHP_SELF?>">AD D A RECORD</a>
<P>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($id) {
// editing so select a record
$sql = "SELECT * FROM research_main WHERE id=$id";
$result = mysql_query($sq l);
$myrow = mysql_fetch_arr ay($result);
$id = $myrow["id"];
$date_event = $myrow["date_event "];
$info_research = $myrow["info_resea rch"];
$medium_name = $myrow["medium_nam e"];
$place_name = $myrow["place_name "];
$date_invest = $myrow["date_inves t"];
$verified_event = $myrow["verified_event "];
$closed_event = $myrow["closed_eve nt"];
// print the id for editing
?>
<p>
<input type=hidden name="id" value="<?php echo $id ?>">
<?php
}
?>
</p>
<table width="803" border="0">
<tr>
<td width="284">&nb sp;</td>
<td width="509">&nb sp;</td>
</tr>
<tr>
<td>Date Of Event: <span class="style1"> yyyy-mm-dd</span> </td>
<td><input name="date_even t" type="Text" value="<?php echo
$date_event ?>" size="10"></td>
</tr>
<tr>
<td valign="top">Re search Details</td>
<td bordercolor="#0 00000"><textare a name="info_rese arch"
rows="10"><?php echo $info_research ?></textarea></td>
</tr>
<tr>
<td valign="top">Na me of Medium or Researcher:</td>
<td bordercolor="#0 00000"><input name="medium_na me" type="Text"
id="medium_name 2" value="<?php echo $medium_name ?>" maxlength="30"> </td>
</tr>
<tr>
<td valign="top">In vestigation Location:</td>
<td bordercolor="#0 00000"><input name="place_nam e" type="Text"
id="place_name3 " value="<?php echo $place_name ?>" maxlength="50"> </td>
</tr>
<tr>
<td valign="top">Da te to be researched: <span
class="style1"> yyyy-mm-dd</span> </td>
<td bordercolor="#0 00000"><input name="date_inve st" type="Text"
id="date_invest " value="<?php echo $date_death ?>" size="10"></td>
</tr>
<tr>
<td valign="top">Re search Verified:</td>
<td bordercolor="#0 00000"><input name="verified_ event" type="radio"
value="Yes">
YES
<input name="verified_ event" type="radio" value="No" checked>
NO</td>
</tr>
<tr>
<td valign="top">Re search Closed:</td>
<td bordercolor="#0 00000"><input name="closed_ev ent" type="radio"
value="Yes">
YES
<input name="closed_ev ent" type="radio" value="No" checked>
NO</td>
</tr>
</table>
<p>
<input type="Submit" name="submit" value="Enter information">
</p>
</form>
<?php
}
?>
</body>
</html>