Jump to content

[SOLVED] Sort by field (date)


kemper

Recommended Posts

I would like to display my data but sorted by date.  I have already had some postponed games, so now the results are not displaying in order of date.  Suggestions are greatly appreciated.  My code is below.  Thank you in advance.

 

    // mySQL Table
    $db_con = mysql_connect(****, ****, ****) or die("Connetion to database failed!");
    mysql_select_db(****);
$division = $_GET['division'];
$sql = "SELECT * FROM `s2007schedules` WHERE division='$division'";
$result = mysql_query($sql) or die(mysql_error());
$i = 0;

    echo "<font face='Arial' size='3'>To report game results, <u>
<a href='http://www.****'>
<font color='#ff0000'>click here<br></font></a></u></font><br><br>\n\n";

echo "</p>
<table width='100%' border='1' cellspacing='0' cellpadding='3' bordercolor='#3c64a0'>";
         
    while ($row = mysql_fetch_array($result)) {
    echo "<tr>
    <td valign='top' width='100%'>
    <table border='1' width='100%' id='table1' cellspacing='0' cellpadding='2'>
	<tr>
		<td width='55%' colspan='3' bgcolor='#3c64a0'><font face='Arial' size='2' color='#ffffff'><b>" . $row['date'] . "</b></font></td>
		<td width='45%' colspan='2'><b><font face='Arial' size='2' color='#ff0000'>
		Status: </font></b><font face='Arial'>" . $row['status'] . "</font></td>
	</tr>
	<tr>
		<td width='2%'> </td>
		<td width='47%'><font face='Arial' size='2'>" . $row['visitor'] . "</font></td>
		<td width='6%'><font face='Arial' size='2' color='#FF0000'><center><b>" . $row['v_score'] . "</b></center></font></td>
		<td width='30%'><font face='Arial' size='2' color='#2b538e'><b> " . $row['time'] . "</b></font></td>
		<td width='15%'><font face='Arial' size='2'><center><b>Game ID:</b></center></font></td>
	</tr>
	<tr>
		<td width='2%'>
		<p align='right'><b><font face='Arial' size='2' color='#FF0000'><center>@</center></font></b></td>
		<td width='47%'><font face='Arial' size='2'>" . $row['home'] . "</font></td>
		<td width='6%'><font face='Arial' size='2' color='#FF0000'><center><b>" . $row['h_score'] . "</b></center></font></td>
		<td width='30%'>
		<a target='_blank' href=" . $row['field_link'] . "><font face='Arial' size='1' color='#ff0000'><b><u>" . $row['field'] . " " . $row['field_no'] . "</u></b></font></a></td>
		<td width='15%'><font face='Arial' size='1'><center>" . $row['gameid'] . "</center></font></td>
	</tr>
</table>
</td>
    </tr>";
    }
echo "</table>\n";

  // mySQL ends

Link to comment
Share on other sites

So...  My satetement is:

$sql = "SELECT * FROM `s2007schedules` WHERE division='$division'";

 

Can I add it to my statement?

Would it be:

$sql = "SELECT * FROM `s2007schedules` WHERE division='$division' WHERE field='$date' ORDER BY datefield ASC";

 

Link to comment
Share on other sites

You have 2 Where statements in there, that wont work at all...try this...

 

$sql = "SELECT * FROM `s2007schedules` WHERE division='$division' ORDER BY datefield ASC";

 

you must replace datefield with the field that contains your dates in your table

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.