I am new to PHP and I am trying make a page that displays the entries in a table and then gives the option to delete a specific entry after checking it. I can get the page to display the entries and there is a link to delete the entry but it will not pass the variable to the second page that deletes the entry. Here is my code.
This is the page that displays the entries:
[code=php]<?php
include 'datacon.php';
$result = mysql_query("SE LECT * FROM stationfailuret est");
echo "<table border='1'>
<tr>
<th>Station Failures</th>
<td>ID</td>
<td>Cube Number</td>
<td>Phone Number</td>
<td>Agent Name</td>
<td>Agent ID</td>
<td>Problem</td>
</tr>";
while($row = mysql_fetch_arr ay($result))
{
echo "<tr>";
echo "<td><a href=\"list2.ph p?ID=";
echo $row['id'];
echo "\" TARGET=main>";
echo "Delete</a></td>";
echo "<td>".$row['id']."</td>\n";
echo "<td>".$row['Cube_Number']."</td>\n";
echo "<td>".$row['Phone_Number']."</td>\n";
echo "<td>".$row['Agent_Name']."</td>\n";
echo "<td>".$row['Agent_ID']."</td>\n";
echo "<td>".$row['Problem']."</td>\n";
echo "</tr>";
}
echo "</table>";
mysql_close($co n);
?>
Here is the code of the page that is supposed to delete the entry:
<?php
switch (ID)
{
default:
echo "<b>";
include 'datacon.php';
$result = mysql_query("DE LETE FROM stationfailuret est WHERE id = '".$ID."'");
mysql_close($co n);
break;
}
?>[/code]
If I hard code the number of the ID into the second page it deletes the entry but not if I leave it to use the passed variable.
Please Help
This is the page that displays the entries:
[code=php]<?php
include 'datacon.php';
$result = mysql_query("SE LECT * FROM stationfailuret est");
echo "<table border='1'>
<tr>
<th>Station Failures</th>
<td>ID</td>
<td>Cube Number</td>
<td>Phone Number</td>
<td>Agent Name</td>
<td>Agent ID</td>
<td>Problem</td>
</tr>";
while($row = mysql_fetch_arr ay($result))
{
echo "<tr>";
echo "<td><a href=\"list2.ph p?ID=";
echo $row['id'];
echo "\" TARGET=main>";
echo "Delete</a></td>";
echo "<td>".$row['id']."</td>\n";
echo "<td>".$row['Cube_Number']."</td>\n";
echo "<td>".$row['Phone_Number']."</td>\n";
echo "<td>".$row['Agent_Name']."</td>\n";
echo "<td>".$row['Agent_ID']."</td>\n";
echo "<td>".$row['Problem']."</td>\n";
echo "</tr>";
}
echo "</table>";
mysql_close($co n);
?>
Here is the code of the page that is supposed to delete the entry:
<?php
switch (ID)
{
default:
echo "<b>";
include 'datacon.php';
$result = mysql_query("DE LETE FROM stationfailuret est WHERE id = '".$ID."'");
mysql_close($co n);
break;
}
?>[/code]
If I hard code the number of the ID into the second page it deletes the entry but not if I leave it to use the passed variable.
Please Help
Comment