View Single Post
Old 02-10-2005, 09:08 PM  
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Quote:
For every message received, what would be the best way of updaitng the table?
You can do something to this effect....
Code:
$username = $_COOKIE['username']; //What user are we updating ?
$chattext = $_POST['chattext']; //What text did this user submit ?

//Let's check to see if this username is in the table.
$usernamequery = "SELECT username FROM members WHERE username='$username';
$username = @mysql_query($usernamequery);
$numusername = mysql_num_rows($username);//Does this username exist ?

if ($numusername = 0) {//If username doesn't exist add to table.
$adduserquery = "INSERT INTO members (username,chattext) VALUES ('$username', '$chattext');
}
elseif ($numusername = 1) {//If the username already exists update chattext.
$updatechat = "UPDATE members SET chattext='chattext{$_POST['chattext']}'"
}
In this example a form is being used to pass the values to the variables.
__________________
subarus.

Last edited by calmlikeabomb; 02-10-2005 at 09:09 PM..
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote