Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7420421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:14:10+00:00 2026-05-29T08:14:10+00:00

I create some site and now I create a message system. For it I

  • 0

I create some site and now I create a message system. For it I create mysql inbox_msg base (from,to,subject,date,time,message,file1,file2,file3,unread).
And now I don’t know, how create PHP-script to print it’s message’s.
Now it looks like this:

<?
session_start();
$user = $_SESSION['login'];
$mysql_connect = mysql_connect("localhost", "root", "");
$mysql_select_db = mysql_select_db("site");
$sql = "SELECT * FROM `msg_inbox` WHERE `to` = '$user'";
$result = mysql_query($sql) or die(mysql_error());
$sql1 = "
    UPDATE `msg_inbox`
    SET `unread` = 0
    WHERE `to` = '" . mysql_real_escape_string($user) . "'
  ";
$result1 = mysql_query($sql1) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
        <br>
        From: <?= $row['from'] ?>
        <br>
        Date: <?= $row['date'] ?> at <?= $row['time'] ?>
        <br>
        <br>
        <?= $row['message'] ?>
        <br>           
        <HR>     
}
?>

But it’s no good: I have a problem to add delete button and other. Can you help me?
Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:14:11+00:00Added an answer on May 29, 2026 at 8:14 am

    To begin with, the code 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 echo function in PHP.

    Here’s how you could rewrite the while loop using echo:

    while ($row = mysql_fetch_array($result)) {
       echo("<br/>From: ".$row['from']."<br/>");
       echo("Date: ".$row['date']." at ".$row['time']."<br/><br/>");
       echo($row['message']);
       echo("<br/><HR>");
    }
    

    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 form element. When the user clicks the button then, the form will do perform a an HTTP POST, or GET (depending on the method attribute you put on the form element). The page it POSTs or GETs is controlled by yet another attribute of the form element, named action.

    Here’s an example:

     <form id='frmMessageView' name='frmMessageView' method='POST' action='delete_message_script.php'>
         <input id='btnDelete' name='btnDelete' type='submit' value='Delete Message' />
     </form>
    

    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.

    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.

    Finally, once you get the idea, read about form post-back. That is the mechanism of posting back to the same page (script).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble POSTing data from a client machine to our internal site
On my site when some user create profile he also choose his school name.
I have a question that I've been trying to answer for some time now
Just created a WSS site with a some custom web-parts. But I get an
I have some code that creates a new site in SharePoint. Upon browsing to
I have some code on my PHP powered site that creates a random hash
I create some dynamic textbox's and a button in a placeholder and would like
I create some documentation in the Trac wiki. I set these pages to all
i create some project but when start App. How to Run this App one
Lets create some interfaces public interface ITimeEventHandler { string Open(); } public interface IJobTimeEventHandler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.