Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Possible? Two MYSQL Queries?
Old 12-20-2005, 03:32 PM Possible? Two MYSQL Queries?
NuWeb.co.uk's Avatar
NuWeb.co.uk is OFFLINE

Posts: 361
Trades: 0
This is my current query:
Code:
$sql_query = "SELECT * FROM games WHERE gameid = $gameid";
        //store the SQL query in the result variable
		    $result = mysql_query($sql_query);
		    if(mysql_num_rows($result))
		    {
		    //output as long as there are still available fields
		    while($row = mysql_fetch_array($result))
		    {
		    
		    $gamefile = $row[gamefile];
		    $gamelocation = $row[gamelocation];
			   }
         }
What i want to do is also update timesplay, so basicaly +1
I was wondeing instead of createing annouther query, is it not possible to do something on the lines of:

Code:
$sql_query = "SELECT * FROM games WHERE gameid = $gameid; UPDATE games SET gamesplay = '1'";
__________________

Please login or register to view this content. Registration is FREE


NuWeb 10101101
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
 
Register now for full access!
Old 12-20-2005, 03:53 PM
RoLLiNLoW54's Avatar
Super Talker

Posts: 116
Location: Canandaigua, NY
Trades: 0
Quote:
Originally Posted by NuWeb.co.uk
This is my current query:
Code:
$sql_query = "SELECT * FROM games WHERE gameid = $gameid";
        //store the SQL query in the result variable
		    $result = mysql_query($sql_query);
		    if(mysql_num_rows($result))
		    {
		    //output as long as there are still available fields
		    while($row = mysql_fetch_array($result))
		    {
		    
		    $gamefile = $row[gamefile];
		    $gamelocation = $row[gamelocation];
			   }
         }
What i want to do is also update timesplay, so basicaly +1
I was wondeing instead of createing annouther query, is it not possible to do something on the lines of:

Code:
$sql_query = "SELECT * FROM games WHERE gameid = $gameid; UPDATE games SET gamesplay = '1'";

this will have to be done in two separate queries. mysql handles each query separately. as long as you are only connecting once, you shouldn't be suffering any loading lag if that is what you are worried about. but, the code that you posted would generate an SQL error.

also, in theory, to do what you're trying to do, you'll probably actually need 3 queries, one to select the game, one to retrieve how many times it has been played, then +1 with php, then a third query to update the number of times played
__________________

Please login or register to view this content. Registration is FREE
: A distinguished web presence begins with distinguished web developers.
RoLLiNLoW54 is offline
Reply With Quote
View Public Profile Visit RoLLiNLoW54's homepage!
 
Old 12-20-2005, 03:58 PM
NuWeb.co.uk's Avatar
NuWeb.co.uk is OFFLINE

Posts: 361
Trades: 0
Thanks, The quary actuarly works
$gameid is found from the url ?gameid=1


Thanks for the help, i was just wanting to cut down my codeing my allot.
__________________

Please login or register to view this content. Registration is FREE


NuWeb 10101101
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
Old 12-20-2005, 04:00 PM
RoLLiNLoW54's Avatar
Super Talker

Posts: 116
Location: Canandaigua, NY
Trades: 0
Quote:
Originally Posted by NuWeb.co.uk
Thanks, The quary actuarly works
$gameid is found from the url ?gameid=1


Thanks for the help, i was just wanting to cut down my codeing my allot.
interesting.. didn't think that query would work being separated like that. I guess my mysql knowledge has gone out the window now that I use Oracle more often

glad you figured out your problem!
__________________

Please login or register to view this content. Registration is FREE
: A distinguished web presence begins with distinguished web developers.
RoLLiNLoW54 is offline
Reply With Quote
View Public Profile Visit RoLLiNLoW54's homepage!
 
Old 12-21-2005, 09:35 AM Q
Novice Talker

Posts: 12
Trades: 0
are you using mysqli ? you didn't include the code to open the db connection.

if the db connection is still open, yes, you can put two queries through, but make sure that you label the $query and $result as a different name from the first.
synapsex is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Possible? Two MYSQL Queries?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27542 seconds with 12 queries