How to build a page to execute a query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Alpal
Forum Commoner
Posts: 39
Joined: Mon Jul 26, 2010 4:08 am

How to build a page to execute a query

Post 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.
thecodewall
Forum Commoner
Posts: 33
Joined: Sun Dec 26, 2010 8:37 am

Re: How to build a page to execute a query

Post 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...
Alpal
Forum Commoner
Posts: 39
Joined: Mon Jul 26, 2010 4:08 am

Re: How to build a page to execute a query

Post 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)
Post Reply