Jump to content

delete specific row out of 3


SirChick

Recommended Posts

no an example would be

 

"if delete message 2 is yes then "mysql code here"

 

But message 2 could be any ID number out of thousands... so i find the messages which are the user's inbox messages and then out of them itll pick the second message ... the max inbox is 3 messages so they have to delete one of the 3 in order to receive a 4th message. etc

Link to comment
Share on other sites

Oh, I think I understand.

 

In their inbox when they view a message, it uses the auto incremented ID, correct? Just pass it along in the URL via GET, and have a button saying "delete", and use something like this:

 

<?php
$messageID=$_GET['messageID'];
mysql_query("delete from messages where messageID='$messageID'");
?>

Link to comment
Share on other sites

umm i dont know if i understand that... lets pretend we have 3 rows:

 

row 1 = ID is 2424

row 2 = ID is 2342424

row 3 = ID is 2

 

Now the mysql has to delete position of row 2 cos it will always and only ever have 3 to choose from and their sorted via newest at the top and oldest to the bottom..

Link to comment
Share on other sites

Sorry actually that is bad logic.

 

Because if you have 3 rows and you always put the data in them and you delete a row how you going to use the database template?

 

So you will need to either update the information in a row with empty value and not delete it, or you will need to create the row again next time and assign row_number=2 to it.

 

Updating with empty value is the best choice because the template is static.

Link to comment
Share on other sites

I don't see the point in updating it to a blank record...

 

basically say theres 3 rows.. i need a way for those 3 rows that are found from a query to be put into an array so i can pick which row of the 3 found i want to delete.. it can be any one of them 3 rows that can be deleted and their ID's could be of any number.

Link to comment
Share on other sites

But you need to assign some sort of index to the rows in order to delete them or to update with empty field value.

 

Or you need to search for spefic value to identify which row you need to modify.

 

For example variable_1  variable_2 variable_3

                row 1 =a1            =a2              =a3

                row 2 =b1            =b2              =b3

                row 3 =c1

Now we give a MYSql command to delete or update row if variable_2=a2 or what ever specific value your chose.

There has to be an identifiable key, or if the database always has 3 rows only, it is a static template and you just feel the values in row 2 with empty fields accept the key of the row which you need to asign to a variable called row_id

Link to comment
Share on other sites

Oh, I think I understand.

 

In their inbox when they view a message, it uses the auto incremented ID, correct? Just pass it along in the URL via GET, and have a button saying "delete", and use something like this:

 

<?php
$messageID=$_GET['messageID'];
mysql_query("delete from messages where messageID='$messageID'");
?>

 

That is right.

 

You create your query which grabs the first 3 rows, these are the newest in the database.

 

$select = mysql_query('SELECT * FROM messages LIMIT 3');

 

Assuming that the ID field is the first field, you render out a link with each row.

 

while($message = mysql_fetch_row($select)){

      echo 'Name' . '<a href="index.php?delete=true&id=' . $message[0] . '">Delete?</a>'

}

 

That will render out a link, with a dynamic delete link, for each row.

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.