PDA

View Full Version : URGENT - PHP not working..



Luke
15-06-2013, 11:24 AM
Basically, I have this code;

<?php
$query = "select *
from `winningflight`
order by points desc";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo $row['flight'];
?>

This is the table
http://i.imgur.com/qHORvn4.png

It always shows A, not B

Chippiewill
15-06-2013, 12:21 PM
I personally can't see a problem with the code, maybe add limits. Also the MySQL bindings just got deprecated, you may want to use the MySQLi ones instead.

Luke
15-06-2013, 12:39 PM
I personally can't see a problem with the code, maybe add limits. Also the MySQL bindings just got deprecated, you may want to use the MySQLi ones instead.

I had a limit, but that didn't work:/ And I don't 100% know what that means :')

Chippiewill
15-06-2013, 01:05 PM
"LIMIT 0,1" on the end of your mysql query will return just one result starting at the first result.

Luke
15-06-2013, 01:17 PM
I sorted it using MAX, but thanks Chippie!

Zak
16-06-2013, 10:44 AM
In future (when your table gets a little more info) you may want to limit the query to the field names you want to return to optimise performance :)

Want to hide these adverts? Register an account for free!