Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-27-2009, 08:29 AM   PM User | #1
ajloun
Regular Coder

 
Join Date: Aug 2009
Posts: 215
Thanks: 74
Thanked 0 Times in 0 Posts
ajloun has a little shameless behaviour in the past
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 :)
ajloun is offline   Reply With Quote
Old 08-27-2009, 08:56 AM   PM User | #2
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
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);

?>
Phil Jackson is offline   Reply With Quote
Old 08-27-2009, 08:58 AM   PM User | #3
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
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
Phil Jackson is offline   Reply With Quote
Old 08-27-2009, 09:01 AM   PM User | #4
ajloun
Regular Coder

 
Join Date: Aug 2009
Posts: 215
Thanks: 74
Thanked 0 Times in 0 Posts
ajloun has a little shameless behaviour in the past
Thank you .. i'm working oN it
ajloun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:07 AM.


Advertisement
Log in to turn off these ads.