That's not populating the id #. In case I've missed something, here's the full code of the page:
<?php
$con = mysql_connect("server", "user", "pass");
if (!con)
{
die('Could not connect: '. mysql_error());
}
mysql_select_db("outage", $con);
$result = mysql_query("SELECT * FROM `outage`");
echo "<table>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>Date</th>";
echo "<th>Time</th>";
echo "<th>Status</th>";
echo "<th>Planned/Unplanned</th>";
echo "<th>MTC/Plant</th>";
echo "<th>City</th>";
echo "<th>Node</th>";
echo "<th>Services</th>";
echo "<th>Customer Count</th>";
echo "<th>CBS Customers Affected?</th>";
echo "<th>Impact</th>";
echo "<th>Description</th>";
echo "</tr>";
//display the data
while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rows as $data)
{
echo "<td align='center'>". $data . "</td>";
}
echo '<td><a href="update.php?id='.$row['id'].'">update</a></td></tr>';
}
echo "</table>";
?>
And here is the code that inserts data into the database:
<?php
$con = mysql_connect("server", "user", "pass");
if (!con)
{
die('Could not connect: '. mysql_error());
}
if(get_magic_quotes_gpc()) {
$outagedate = stripslashes($_POST['date']);
$outagetime = stripslashes($_POST['time']);
$outagetype = stripslashes($_POST['outagetype']);
$mtcplant = stripslashes($_POST['mtcplant']);
$outagecity = stripslashes($_POST['city']);
$outagenode = stripslashes($_POST['node']);
$services = stripslashes($_POST['services']);
$custcount = stripslashes($_POST['custcount']);
$cbs = stripslashes($_POST['cbs']);
$impact = stripslashes($_POST['impact']);
$outagedesc = stripslashes($_POST['desc']);
$status = stripslashes($_POST['status']);
} else {
$outagedate = $_POST['date'];
$outagetime = $_POST['time'];
$outagetype = $_POST['outagetype'];
$mtcplant = $_POST['mtcplant'];
$outagecity = $_POST['city'];
$outagenode = $_POST['node'];
$services = $_POST['services'];
$custcount = $_POST['custcount'];
$cbs = $_POST['cbs'];
$impact = $_POST['impact'];
$outagedesc = $_POST['desc'];
$status = $_POST['status'];
}
mysql_select_db("outage", $con);
$sql = sprintf("INSERT INTO `outage`.`outage` (`date`, `time`, `status`, `outagetype`, `mtcplant`, `city`, `node`, `services`, `custcount`, `cbs`, `impact`, `desc`) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
mysql_real_escape_string($outagedate, $con),
mysql_real_escape_string($outagetime, $con),
mysql_real_escape_string($status, $con),
mysql_real_escape_string($outagetype, $con),
mysql_real_escape_string($mtcplant, $con),
mysql_real_escape_string($outagecity, $con),
mysql_real_escape_string($outagenode, $con),
mysql_real_escape_string($services, $con),
mysql_real_escape_string($custcount, $con),
mysql_real_escape_string($cbs, $con),
mysql_real_escape_string($impact, $con),
mysql_real_escape_string($outagedesc, $con));
mysql_query($sql, $con);
if (mysql_affected_rows($con) > 0) {
echo "Outage Inserted\n";
}
else {
echo "Fill the form properly\n";
}
mysql_close($con)
?>