rwachowiak Posted March 13, 2008 Share Posted March 13, 2008 heres what i got so far: when i click the delete link it wants to actually download the update.php <?php include 'libs/dbopen.php'; //If cmd is not hit if(!isset($cmd)) { $query = "SELECT * FROM news Order by DateAdded DESC"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<span class='titlebar3'><a href='update.php?cmd=delete&id={$row['id']}'>{$row['Title']} - Delete</a></span><br>" . "{$row['Content']} <br>" . "<span class='description'>Date Added: {$row['DateAdded']}</span> <br><br>"; } } ?> <? if($cmd=="delete") { $sql = "DELETE FROM news WHERE id={$row['id']}"; $result = mysql_query($sql); echo "Row deleted!"; } include 'libs/dbclose.php'; ?> Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/ Share on other sites More sharing options...
revraz Posted March 13, 2008 Share Posted March 13, 2008 Just a shot here, since I assume you mean the update.php and not upload.php and assuming PHP is installed and works. Try to change your <? tag to <?php Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/#findComment-491332 Share on other sites More sharing options...
rwachowiak Posted March 13, 2008 Author Share Posted March 13, 2008 Just a shot here, since I assume you mean the update.php and not upload.php and assuming PHP is installed and works. Try to change your <? tag to <?php whoops yes, it is update.php and yes php is installed and working fine, i have a few other scripts ive got going on this site and i tried that <?php and no luck! Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/#findComment-491333 Share on other sites More sharing options...
revraz Posted March 13, 2008 Share Posted March 13, 2008 When you hover over the URL, how does it look in your status bar? Also, where do you $_GET['cmd'] and $_GET['id'] ? Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/#findComment-491337 Share on other sites More sharing options...
rwachowiak Posted March 13, 2008 Author Share Posted March 13, 2008 When you hover over the URL, how does it look in your status bar? Also, where do you $_GET['cmd'] and $_GET['id'] ? links look like: http://srv2/update.php?cmd=delete&id=1 what do you mean where do i get those?! i suppose im missing something lol Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/#findComment-491340 Share on other sites More sharing options...
revraz Posted March 13, 2008 Share Posted March 13, 2008 <?php if($_GET['cmd']=="delete") { $sql = "DELETE FROM news WHERE id={$_GET['id']}"; $result = mysql_query($sql) or die (mysql_error()); echo "Row deleted!"; } include 'libs/dbclose.php'; ?> Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/#findComment-491341 Share on other sites More sharing options...
rwachowiak Posted March 13, 2008 Author Share Posted March 13, 2008 <?php if($_GET['cmd']=="delete") { $sql = "DELETE FROM news WHERE id={$_GET['id']}"; $result = mysql_query($sql) or die (mysql_error()); echo "Row deleted!"; } include 'libs/dbclose.php'; ?> works great thanks Link to comment https://forums.phpfreaks.com/topic/95975-deleting-a-row-with-a-link-mysql/#findComment-491359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.