Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    Disable Data From Mysql Table

    Hello

    Sorry Lately i been posting too many Quastions , Forgive me , Just trying to learn . and i ask when i dont know how to get it right .

    Now the quastion is .

    I have Mysql .. there is a Tabel Called Message with 3 Rows (sender , Reciver , Message ) .. Now i need to make little script . reads the data from the tabel . like this

    1- Sender of the Message
    2- Reciver of the Message
    3-the Message

    the script will print Out the message that Been Sent between the Sender and the Reciver .. when spicif the sender id and the Reciver id ..
    Please see the Html form for More understanding

    [PHP<html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>

    <body>

    <form method="POST" action="--WEBBOT-SELF--">
    <!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" --><p>
    <input type="text" name="T1" size="20" value="Sender">&nbsp;&nbsp; To&nbsp;&nbsp;
    <input type="text" name="T2" size="20" value="Reciver"><input type="submit" value="Show me the Message" name="B1"></p>
    <p>Print Out the Message here ...</p>
    </form>

    </body>

    </html>[/PHP]
    Last edited by ajloun; 08-27-2009 at 08:34 AM. Reason: Not Disable Data From Mysql Tabel But Preview data . Sorry :)

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:
    <?php

    $con 
    mysql_pconnect("localhost""username""password");
    $db mysql_select_db("databasename"$con);

    $reciever "JohnDoe";
    $query mysql_query("SELECT * FROM `Message` WHERE Reciever = '$reciever' order by ID DESC");
    if(
    mysql_num_rows($query)!=0)
    {
        while(
    $array mysql_fetch_array($query))
        {
            
    $DBsender $array['sender'];
            
    $DBreciever $array['Reciever'];
            
    $DBmessage $array['Message'];
        
            
    ?>
            <p>your html would go here using the variables above</p>
            <?php
        
    }
    }
    else
    {
        echo 
    "No messages in you inbox";    
    }
    mysql_close($con);

    ?>

  • #3
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    The above code is something i've just knocked up in 2mins, but its a great start for you to adapt it as you learn more.

    EDIT: i noticed you haven't got an ID in your mysql table - i would add one - auto_increment - index

  • #4
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thank you .. i'm working oN it


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •