Yes. What I am doing is calling it from another page which displays the stopdate (date entered), stop (stop mileage) and calling it with this tag so I can update it: <a href=\"UpdateMileage.php?vid=$vid\" onclick=\"NewWindow(this.href,'name','340','210','yes');return false;\">.
Once the UpdateMileage.php comes up it displays the vehicle reg number with the last mileage update information. I then fill in the cells with the new info and submit. It states it was successful however the db was never updated.
This is the entire code:
<?
include("config.inc");
$link = mysql_connect ($server, $user, $password);
if (! $link)
{
die ("Couldn't connect to mySQL server");
}
if (!mysql_select_db ($db, $link) )
{
die ("Couldn't open $db: ".mysql_error() );
}
$chk_id = "SELECT vid from lsv WHERE vid = \"$vid\"";
$chk_id_res = @($chk_id,$link) or die("Couldn't execute query.");
$chk_id_num = mysql_num_rows($chk_id_res);
if ($chk_id_num == "0") {
echo "<p> <i><font size=3 face=verdana>Sorry, No Records Found!</font></i></p>";
echo "<p><center><font face='verdana' size='2'>[ <a href=\"?\" onClick=window.close();>Close Window</a> ]</font></center></p>";
exit;
} else {
$sql = "SELECT * FROM lsv WHERE vid = \"$vid\"";
$sql_result = mysql_query($sql,$link) or die ("Couldn't execute Query!");
while ($row = mysql_fetch_array($sql_result)) {
$vid = $row['vid'];
$reg = $row['reg'];
$stopdate = $row['stopdate'];
$stop = $row['stop'];
}
}
$form_block = "
<form method=\"post\" action=\"$PHP_SELF\">
<input type=\"hidden\" name=\"vid\" value=\"$vid\">
<table border='0' width='300' cellpadding='1' cellspacing='1'>
<tr>
<td><font face='verdana' size='2'><b>Update mileage on: $reg</b></font><br><br></td>
</tr>
</table>
<table border='0' width='300' cellpadding='1' cellspacing='1'>
<tr>
<td><b><font face='verdana' size='2'>Date:</font></b></td>
<td><input type=\"text\" name=\"stopdate\" value=\"$stopdate\" size=\"10\" maxlength=\"50\"> <font size='1'>(YYYY-MM-DD)</font></td>
</tr>
<tr>
<td valign='top'><b><font face='verdana' size='2'>Total Mileage:</font></b></td>
<td><input type=\"text\" name=\"stop\" value=\"$stop\" size=\"10\" maxlength=\"30\"> </td>
</tr>
<tr>
<td></td>
<td><input type=\"hidden\" name=\"op\" value=\"ds\">
<input type=\"submit\" name=\"submit\" value=\"Update Mileage\"></td>
</tr>
</table>
</form>
<p><center><font face='verdana' size='2'>[ <a href=\"?\" onClick=window.close();>Close Window</a> ]</font></center></p>
";
if ($op != "ds") {
echo "$form_block";
}
elseif ($op == "ds") {
if ($stopdate == "0000-00-00") {$stopdate_error = "<font color='red' face='arial' size='1'>Please Enter Date!</font><br>";
$submit = "no"; }
if ($stopdate == "") { $stopdate_error = "<font color='red' face='arial' size='1'>Please Enter Date!</font><br>";
$submit = "no"; }
if ($stop == "0") { $stop_error = "<font color='red' face='arial' size='1'>Please Enter Mileage!</font><br>";
$submit = "no"; }
if ($stop == "") { $stop_error = "<font color='red' face='arial' size='1'>Please Enter Mileage!</font><br>";
$submit = "no"; }
if ($submit != "no") {
$sql = "UPDATE lsv
SET
stopdate = \"$stopdate\",
stop = \"$stop\"
WHERE vid = \"$vid\"
";
echo "<p><i><font size='2' face='verdana'>$reg Mileage Update Successful!</font></i></p>";
echo "<p><center><font face='verdana' size='2'>[ <a href=\"?\" onClick=window.close();>Close Window</a> ]</font></center></p>";
$sql_result = mysql_query($sql,$link) or die ("Couldn't execute Query!");
}
if ($submit == "no") {
echo "$stopdate_error";
echo "$stop_error";
echo "$form_block";
}
}
?>
Once Again
Thanks