Page 1 of 1

How to build a page to execute a query

Posted: Tue Jan 04, 2011 11:18 pm
by Alpal
Hi
Have this query:
UPDATE `mydatabase`.`xxscrs` SET `RP_bill`=(SELECT SUM(xxscrs.player_total)*50)
Have run the query from my cpanel in phpmyadmin and it does what I want it to do. Obviously it updates the whole table and calculates a players "ranking points"
What I would like to do is now build a page in the database so when scores have been inserted into the "xxscrs" table, it can then be updated.
Not sure where to start
Any help would be greatly appreciated.

Re: How to build a page to execute a query

Posted: Tue Jan 04, 2011 11:46 pm
by thecodewall
Here's my code.]
to insert user in user table:

Code: Select all

$q = "INSERT INTO user (username,password,lname,fname) VALUES ('".$_POST['username_i']."','".$_POST['password']."','".$_POST['lname']."','".$_POST['fname']."')";
$query = mysql_query($q) or die(mysql_error());
to update in user table:

Code: Select all

$q = "UPDATE user SET password='".$_POST['password']."', lname='".$_POST['lname']."', fname='".$_POST['fname']."' WHERE username='".$_POST['username']."'" ;
$query = mysql_query($q) or die(mysql_error());		
hope this help...

Re: How to build a page to execute a query

Posted: Wed Jan 05, 2011 12:09 am
by Alpal
Sorry
Probably did not explain properly
Have a database running and insert / edit pages working.
Just need a simple page, with a form and submit button that will run this query
UPDATE `mydatabase`.`xxscrs` SET `RP_bill`=(SELECT SUM(xxscrs.player_total)*50)