Jump to content

unnormaldude68

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

unnormaldude68's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you very much for your help. I got it to work
  2. $id is an auto_increment field in the table. When I hover over the Delete link, &id in the status bar correctly shows the id of the row. So that part is working.
  3. Hi, I have a script that calls certain data from tables in my database. I want to be able to delete a specific row from the php page. I have currently added a link in the table that will delete a row when clicked, however, it always deletes the last row and not the one that I want it to delete. Here is the code: <?php $con = mysql_connect('localhost', '****', '****'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("****", $con); $sql="SELECT * from flash"; $result = mysql_query($sql); echo' <HTML> <head> <title>Bans</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="table.js"></script> <link rel="stylesheet" type="text/css" href="themes/blue/style.css" /> </head> <body bgcolor="#cccccc"> '; echo' <table id="myTable" class="tablesorter"> <script type="text/javascript"> $(document).ready(function() { $("table").tablesorter({ // sort on the first column and third column, order asc sortList: [[0,0]] }); }); </script> <thead> <tr> <th>ID</th> <th>Moderator</th> <th>User</th> <th>Action</th> <th>Length</th> <th>Date</th> <th>Delete</th> </tr> </thead> '; echo' <tbody>'; if(!isset($cmd)) { while($row = mysql_fetch_array($result)) { $id=$row['id']; echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['moderator'] . "</td>"; echo "<td>" . $row['name'] . "</td>"; echo "<td>" . $row['action'] . "</td>"; echo "<td>" . $row['length'] . " minutes</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td><a href='index.php?cmd=delete&id=$id'>Delete</a></td>"; echo "</tr>"; } } if($_GET["cmd"]=="delete") { $sql = "DELETE FROM flash WHERE id=$id"; $result = mysql_query($sql); echo "<meta http-equiv='refresh' content='0; URL=index.php'>"; } echo' </tbody> </table> </body> </HTML>'; ?> Any help would be greatly appreciated. Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.