Jump to content

[SOLVED] Am I missing Something? My Update Querys


Lamez

Recommended Posts

The idea behind this bit of code is to take the previous submitted information, which are the winners of the foot bowl, then to find all the users that have picked that team to win. If they did pick that team, then it will (suppose) take the pnt value, and add it to the db in the foot_picks table, then take their total, and it it there, and update the foot_pnt table. Well nothing is being updated at all!

 

here is the buggy code:

<?php
ob_start();
$path = "../../";
$u_login = "yes";
$admin = "yes";
$rank = "yes";
include ($path."main/include/cons/head.php");
$name = $_POST['name'];
$team = $_POST['team'];
$pnt = $_POST['pnt'];
$q = mysql_query("SELECT * FROM `foot_picks` WHERE `team` = '".$team."' AND `bowl_name` = '".$name."'");
while($f = mysql_fetch_array($q)){
mysql_query("UPDATE `foot_picks` WHERE `team` = '".$team."' SET `pnt` = '".$pnt."'");
$t = mysql_query("SELECT * FROM `foot_pnt` WHERE `user` = '".$f['user']."'");
$n = mysql_fetch_array($t);
$tot = $n['total'] + $pnt;
mysql_query("UPDATE `foot_pnt` WHERE `user` = '".$f['user']."' SET `total` = '".$tot."'");
}
echo "All Done!";
include ($path."main/include/cons/foot.php");
?>

you could actually turn those two selects into 1 query, but thats for later lol

 

SET usually comes before WHERE

 

although I really don't know if that is really important lol

 

 

I really don't see much wrong with your code =\

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.