Don't list 0

A

Anonymous

Guest
Code:
$query = 'SELECT name, points FROM members ORDER BY points DESC LIMIT 0,30';

Ok so that lists people who have the highest points to the lowest. I want it so it does not list people with 0 points.
Just give me a clue, just say either query for something needs to be added to the query, or array for something that needs to go in my array.
 
Code:
$query = "UPDATE members SET `wins` = + 1 WHERE `name` = '{$_POST["winner"]}' AND SET `losses` = +1  WHERE `name` = '{$_POST["loser"]}'";

The query is pretty self explanatory. I want wins to add 1 where name = (the name that they posted) and same with loser. Do I have to do this another way? Or can it be done in the query?

Also, I got an error with this code, saying fetch array is an invalid argument....

Code:
While( $rows = MySQL_fetch_array($result) ) {
$name = $rows['name'];
$location = $rows['location'];
 
HaVoC said:
Code:
$query = "UPDATE members SET `wins` = + 1 WHERE `name` = '{$_POST["winner"]}' AND SET `losses` = +1  WHERE `name` = '{$_POST["loser"]}'";

I think that instead of "SET wins = + 1", what you want is "SET wins = wins + 1". That is, you can't just say "+ 1" .. you need to put something on the other side of the plus sign.

Secondly, once you start your WHERE clause you can't do another SET clause. WHERE always follows SET, SET can never follow WHERE.

Lastly, though I might be wrong about this, you can't UPDATE two different columns according to two different WHERE conditions within the same query. I think you'll have to split it up into two queries.

Code:
$query1 = 'UPDATE members SET wins = wins + 1 WHERE name = ' . $_POST['winner'];

$query2 = 'UPDATE members SET losses = losses + 1 WHERE name = ' . $_POST['loser'];

(Aside not directed at HaVoC: Why are people so fond of those `backticks`? I just don't get it -- they're completely superfluous unless you have funky column names with dashes or spaces or keywords. Also, curly-brace syntax is seriously ugly, IMO. String concatenation, people!)
 
Back
Top