Jump to content

ORDER BY help!


fostersguy

Recommended Posts

Hi there, just registered and in need of help, this looks a good place to start!

I'm a php beginner so please bear with me :)

 

I have a mysql database which holds 3 pieces of info

id:

match:

1:

 

I'm trying to sort the results using ORDER BY match ASC but for some reason it's just not for having it...

Can't work out if it's an error with my php code or my table. I can order by "ID" no problem but I when I try ordering alphabetically by "match" it won't.

 

my code is:

 

mysql_connect("***.***.***") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());


$query = "SELECT * FROM employees WHERE flag = 'tv' ORDER BY match ASC";
$result = mysql_query($query) or die ("Query failed");

$numrows = (mysql_num_rows ($result));


        

// loop to create rows
if($numrows >0){
echo "<table width = 100% border = '0' cellspacing = '2' cellpadding = '0' >";
// loop to create columns
$position = 1;
while ($row = mysql_fetch_array($result)){
if($position == 1){echo "<tr>";}

echo "	<td align = 'center'><a href=\"http://www.website.eu/sport-stream/1/{$row['id']}.html\" target=_blank>{$row['match']}
<br>
<img src=\"{$row['8']}\" width=\"100\" height=\"70\" /> </a>
</td>

"; 
if($position == 4){echo "</tr> "; $position = 1;}else{ $position++;}
}//while

$end = "";
if($position != 1){
for($z=(4-$position); $z>0 ; $z--){
$end .= "<td></td>";
}
$end .= "</tr>";
}

echo $end."</table> ";
}//if

 

And here's a cap of my database:

a0ca19bd2bf9415b8014231.png

 

any help for a php n00b would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/245955-order-by-help/
Share on other sites

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.