Pergunta

I am trying to delete separate messages from a users inbox on my website. The user can go to the inbox, turn on the Delete Messages function which will show an extra HTML checkbox. This checkbox will then update the database to delete each message.

The messages and delete function are shown using the code below:

<p>
  <a href="<?php echo 'http://basecentre.co.uk/', $message["username"]; ?>">
    <img alt="" align="left" hspace="20" height="50" width="50" 
         src="<?php
         echo 'http://basecentre.co.uk/userimages/',
         $message["dp"];
         ?>"> 
  </a>
  <font color='<?php if ($message['unread']) echo '#FF0000'; ?>'>
  <strong> <?php echo $message['first_name']; ?> 
    <?php echo $message['last_name']; ?>  (
    <?php echo date('d/m/Y H:i:s', $message['date']); ?>):
  </strong>
  </font>
  <br />
  <input type="checkbox" name="messageid" value="<?php echo $message['id']; ?>">
  <?php echo $message['text']; ?>
</p>

The code to process the information is still being worked on, however I have hit a snag. The variable shows only ONE message id when it should actually show a list of all message id's that have been marked. Here is the processing code:

<?
/// DELETE MESSAGES
if (isset($_POST['delmessages'])) {
  $delmessage_id = $_POST['messageid'];
  echo $delmessage_id;
  exit();
}
?>

How can I configure the variable to show more than one message id at a time ? Any ideas would be helpful. Thanks!

Foi útil?

Solução

instead of

...  name="foo"... 

in your inputs, you need to use

...  name="foo[] "

and all values will be in array $_POST[" foo"]

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top