Jump to content

Help with deleting records using a form with checkbox type inputs.


kdigital

Recommended Posts

$sql = "SELECT * FROM messages WHERE to_user_id='$to_user_id' LIMIT $offset, $rowsperpage";


  $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR);

  if (empty($numrows))
  {
      $totalpages = 1;

      $error = 'You don\'t have any messages';
  }

  echo "<br />";

  echo "$error" . "<br />";

  echo "<br />";


  echo '<form action="my_messages.php?from_user_id="$from_user_id"" method="POST">';

  echo "<div style=\"float:left; margin-left:5px;\"><input type=\"submit\" name=\"delete\" id=\"button\" value=\"delete\"/></div>";


  echo "<table width=980><tr> <td></td><td><b>From</b></td> <td width=120></td>


       <td width=120><b>Subject</b></td> <td width=120></td>


       <td width=120>Date Sent</td> <td width=120></td>


       <td width=120></td> <td width=120></td></tr>";



      //Fetch data
      while($row = mysql_fetch_assoc($result))
      {


         //$to_user_id = $_SESSION['id'];





         if (isset($_POST['delete']))
         {
             $msg = $_POST['msg'];


             //$from_user_id = $_POST['from_user_id'];


             $from_user_id = $_GET['from_user_id'];

             $query = mysql_query("DELETE FROM messages WHERE from_user_id='$from_user_id'");
         }

         echo "<tr>

               <td><input type=\"checkbox\" name=\"msg\" value=\"".$row["from_user_id"]."\"></td>


               <td>".$row['from_user']."</td>  <td></td>


               <td>".$row['subject']."</td> <td width=300></td>


               <td>".$row['date_sent']."</td>  <td></td>


               <td></td> <td></td>


               <td></td></tr>";



       }



       echo "</form></table>";

Link to comment
Share on other sites

No question

No error message

Just naked code hung out there

for the world to see

How pretty

 

Don't worry about it. Posting this as a job on Odesk. Not going to waste anymore time on coding forums waiting hours and hours for help. I'd rather pay a programmer to code with good notes than post on forums for help and wait for hours for a good response all while crossing my fingers.

Link to comment
Share on other sites

That is likely your best bet. The forums are here for people to learn and share information, so that we can all become better coders, but if you are just looking to get some code fixed, then paying someone to do it will pretty much always be the better way to go.

Edited by haku
Link to comment
Share on other sites

That is likely your best bet. The forums are here for people to learn and share information, so that we can all become better coders, but if you are just looking to get some code fixed, then paying someone to do it will pretty much always be the better way to go.

 

I've actually learned a lot by paying people to fix my code lol. It's the best way to learn to me. Figure out what you want to do and pay someone for it. Make sure they leave plenty of notes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.