Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To begin with, the <em>code</em> inside the while loop is not valid PHP so the script will definitely not run as posted. What you need to do is either mark that code as non-PHP (i.e. HTML markup by closing the PHP script tag after the while loop and reopening before the end of the while) or use an output mechanism such as the <code>echo</code> function in PHP.</p> <p>Here's how you could rewrite the while loop using echo:</p> <pre><code>while ($row = mysql_fetch_array($result)) { echo("&lt;br/&gt;From: ".$row['from']."&lt;br/&gt;"); echo("Date: ".$row['date']." at ".$row['time']."&lt;br/&gt;&lt;br/&gt;"); echo($row['message']); echo("&lt;br/&gt;&lt;HR&gt;"); } </code></pre> <p>As far as the delete button, you could add that to your page as an HTML input element of type submit, and place it inside an HTML <code>form</code> element. When the user clicks the button then, the form will do perform a an HTTP POST, or GET (depending on the <code>method</code> attribute you put on the <code>form</code> element). The page it POSTs or GETs is controlled by yet another attribute of the <code>form</code> element, named <code>action</code>.</p> <p>Here's an example:</p> <pre><code> &lt;form id='frmMessageView' name='frmMessageView' method='POST' action='delete_message_script.php'&gt; &lt;input id='btnDelete' name='btnDelete' type='submit' value='Delete Message' /&gt; &lt;/form&gt; </code></pre> <p>In the example above, when the user clicks the button that says "Delete Message" the browser will perform a POST HTTP request to the delete_message_script.php script.</p> <p>You may wish to read more about HTML form elements, and how a form works (i.e. difference between a POST and a GET request, request variables, and the different types of input elements; also, read about how PHP allows you to process HTTP request variables). In the PHP script that the form posts to you may need to track which button the user clicked to get there (if there is more than one) and which message needs to be deleted.</p> <p>Finally, once you get the idea, read about form post-back. That is the mechanism of posting back to the same page (script). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload