| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Senior Member | Deleting from mysql, ids go the same. When i click on Delete, it will delete the row from the mysql, but it will change all the ids to the same (as the one i deleted) and the row i deleted still shows up. I would need to refresh the page to change the ids back to their original ones and to have the row i deleted to dissapear. How can i do this without pressing the refresh button? The code is: Code: while ($row = mysql_fetch_array($rs))
{
$title = $row["title"];
$url = $row["url"];
$id = $row["id"];
$category = $row["category"];
$description = $row["description"];
if(isset($_GET["delete"])) {
$id = $_GET["delete"];
mysql_query("DELETE FROM tutorials WHERE id='$id' LIMIT 1");
}
echo("<tr><td>$id</td><td>$title</td><td>$category</td><td>$description</td><td>Edit | <a href=\"tutorials.php?delete=$id\">Delete</a></td></tr>");
}
Edit: i just fixed it so they dont all change to the same id (changed the $id in the isset to $tid) But how can i automaticaly refresh it? Edit: i got it to work. Last edited by killaklown; 08-19-2006 at 09:12 AM. |
| |
| | #2 (permalink) |
| NamePros Regular | PHP Code: You overwrite $id and therefore remains constant. Try to change to $sid or some other variable not in use. quote : Edit: i just fixed it so they dont all change to the same id (changed the $id in the isset to $tid) But how can i automaticaly refresh it? [[yea im lazy ]]use the header function. header("Location: http://www.example.com/pageyouwanttogotto");
__________________ Webmaster Toolbox - Affililate Cloaking - How To Lose Pounds Cheesy Pick Up Lines | Learn Spanish CD | Weight Gain Pregnancy | Runescape Cheats |
| |
| | #3 (permalink) |
| NamePros Regular | I think this will be what your looking for: just changed it to make sure the id == the deleted row id. and continued the loop if it did so it doesn't print it out after deleting it. Hope that helps PHP Code: |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |