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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.