Re: [PHP-DB] multiple queries in PHP to mysql database.

2003-03-28 Thread Ronan Chilvers
Hi Jerry

Inline comments

On 28 Mar,2003 at 12:31 JeRRy JeRRy wrote:

 
 How can I update 2 tables at once if a match occours
 from information inputed into a PHP form.
 

How about turning this around and re-organising the data a little?

Why not have a single score table with references to a central username / pw / id 
table.  

Table 1 - users

id
username
password

Table 2 - scores

id
userid
game1
game2
game3
game4
...
overall


You can then do

UPDATE table2 SET game1=game1+1, overall=overall+1 WHERE userid = $userid

Getting a results table would then be a single query...

Does this help at all ?  Hopefully I've grasped enough of the concept to not make a 
complete fool of myself !

 
 Jerry
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] multiple queries in PHP to mysql database.

2003-03-27 Thread JeRRy

Hi,

I just noticed a problem with my question which would
cause major problems in my db.  So let me re-ask it
again.

How can I update 2 tables at once if a match occours
from information inputed into a PHP form.

Now this is what each table has.

table1:
id
username
game1
game2
game3
game4
game5
game6
game7
game8
score

table2:
id
username
password
sid
score

I have this:

$sql = UPDATE table1 SET score=score+1 WHERE
$select='$winner';
   
mysql_query($sql);
echo(Points credited?  I hope!brbr);
}
else {echo(An error occoured, please click back
button and try again.);}

Now that works fine and updates correctly.

But now I want a second table to be updated.  So if
username blah got +1 I need table2 to update it's
score for blah to +1.  The query above updates if it
finda a match in table1 and does not require the use
of a username to update.  But for table2 I am guessing
it WILL need to know the username or id to update the
appropiate field and not update everyones score to +1.
 So how is this achieved? Or am I doing this a hard
way?

Jerry



http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP-DB] multiple queries in PHP to mysql database.

2003-03-27 Thread Blain
Hi

After Updateing the table1:
SELECT username, score FROM table1 WHERE $select='$winner';
Then you have your Informations..

Cya Blain

-Ursprüngliche Nachricht-
Von: JeRRy [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 28. März 2003 02:31
An: [EMAIL PROTECTED]
Betreff: [PHP-DB] multiple queries in PHP to mysql database.



Hi,

I just noticed a problem with my question which would
cause major problems in my db.  So let me re-ask it
again.

How can I update 2 tables at once if a match occours
from information inputed into a PHP form.

Now this is what each table has.

table1:
id
username
game1
game2
game3
game4
game5
game6
game7
game8
score

table2:
id
username
password
sid
score

I have this:

$sql = UPDATE table1 SET score=score+1 WHERE
$select='$winner';

mysql_query($sql);
echo(Points credited?  I hope!brbr);
}
else {echo(An error occoured, please click back
button and try again.);}

Now that works fine and updates correctly.

But now I want a second table to be updated.  So if
username blah got +1 I need table2 to update it's
score for blah to +1.  The query above updates if it
finda a match in table1 and does not require the use
of a username to update.  But for table2 I am guessing
it WILL need to know the username or id to update the
appropiate field and not update everyones score to +1.
 So how is this achieved? Or am I doing this a hard
way?

Jerry



http://mobile.yahoo.com.au - Yahoo! Mobile
- Check  compose your email via SMS on your Telstra or Vodafone mobile.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php