<?php
$db = mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db("makdap", $db) or die("could not get database");
$result = mysql_query("select firstname,lastname,extension from internalphone order by firstname") or die("error w/ query");
//$result = mysql_query("select * from cathchurch order by diocese") or die("error w/ query");
$XX = "No Record Found, to search again please close this window";
//query details table begins
?>
<table width="100%" border="0">
<td width="20%">
<table border="0" bgcolor="#336699" align="center">
<th><font color="white"> Administration </th>
<tr><td bgcolor="#CDDBEB"><font color="#006699"><center>Internal Phone Boook</td></tr>
</table>
<tr>
<td width="20%"> </td>
<td align="center">
<p>
<center>
<table width="100%" border="0" bgcolor="#336699">
<tr>
<?
for ($i = 0; $i < mysql_num_fields($result); $i++) {
print "<td><b><font color="white">".mysql_field_name($result, $i)."</td>";
}
?>
<?
while($myrow = mysql_fetch_row($result)) {
echo "<tr>";
foreach ($myrow as $field){
echo "<td bgcolor=#CDDBEB><font color=#006699>$field</td>";
}
echo "<td bgcolor=#CDDBEB><font color=#006699>ї<a href="">Edit</a>] ї<a href="">Delete</a>]</td>";
echo "</tr>";
}
echo '</table>';
mysql_close($db);
?>
What I want to acomplish is that when the link Edit or Delete are pressed it will delete or allow you to edit the entry it is next to, How can I do this?
There are a few other things, but I would like to get this one done first.
well what does your SQL table look like? the common method is make a 'id' column and set it as auto_increment, that way when a new row of data is injected into the table, it will add a special number to it.
this gives you a way to target specific rows in a table in a db.
well what dont u understand about the example I gave you? you have your table set-up correctly, just target the id column n use the UPDATE feature MySQl offers to edit and use the DELETE feature to delete.
Now when I hover the pointer over the link it only displays delete.php?id= with know id so when i click delete it goes to delete.php and has an error with query.
<?php
$db = mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db("makdap", $db) or die("could not get database");
$result = mysql_query("delete from internalphone where id=".$id) or die("error w/ query");
$XX = "No Record Found, to search again please close this window";
//query details table begins
?>
mckinnon81 wrote:But how do i do that from a hyperlink? How do i tell the hyperlink to run the mysql code to delete the enrty?
Thats what i dont know/understand.
Thanks
Matthew
by pointing the hyperlink to a php script that does just that... and then you could redirect the user from that same script to the page you want them to view... or echo out what you want them to see as a result.
if you want to retain the values and pass them to th e other page, safest route would be to just include the script that has the values on the update script, and go from there..