Jump to content

Selecting Data - Tricky to explain in one sentance


Grego

Recommended Posts

Basically, I have a table in my database with two entries. One of the columns in the table is an "ID" column so I can access particular records. The problem is that the two entries have IDs of "19" and "20". I can't set them to 0 and 1. They are fixed at those numbers.

 

Now my real problem comes when trying to delete them. I have the entries displayed in a list with a checkbox at the right. The checkboxes are "name='ko19'" and "name='ko20'" respectively. Now when I get to the next page, I want to delete the selected ones.

 

I tried to pull everything out of my table, use "mysql_num_rows" to select the number of records then make a for statement from 0 to the result of the num_rows. In the for statement is:

  $strlk="ko" . $i;

  if (isset($_POST[$strlk])) die("Message Found");

 

The problem of course is that there are only two rows in my table. So it never gets up to 19 or 20. My question to you is pretty much how I can create a for statement from 0 to 20 (though 20 will change over time to higher numbers).

 

Here is my whole code:

$count=mysql_num_rows(mysql_query("SELECT * FROM pms"));
for($i=0;$i<=$count;$i++) {
  $strlk="ko" . $i;
  if (isset($_POST[$strlk])) die("boo");
  //mysql_query("DELETE FROM pms WHERE qID=$i");
}

 

Forgot to mention this is PHP, but I'm looking for a mySQL function, I think. Move if appropriate.

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.