GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Oct-2003, 10:34
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road

Sorting A Function


Right I have been very confused due to me not understanding the script section I had been given.
Nothing new then I hear you say.

My points system is calculated from the data in a table that is recalled using normal mysql. Whilst the column points is 0 the calculations are carried out by including points.php which uses a function to calculate the points from the data in the other columns.

Now when the points are calculated they display in the place of the recalled points column.

PHP Code:

$hname = mysql_result($stats,$j,"name");
$hid = mysql_result($stats,$j,"id");
$points = mysql_result($stats,$j,"points");
$games = mysql_result($stats,$j,"games");
$assists = mysql_result($stats,$j,"assists");
$goals = mysql_result($stats,$j,"goals");
    
$position = mysql_result($stats,$j,"position");
$manofthematch = mysql_result($stats,$j,"manofthematch");
$points=points($hid,$se); 
echo ("
<tr bgcolor=\"#ffffff\" align=\"center\" valign=\"middle\">
<td >".$hname."</td>
 <td class=grid2 align=center >".$position."</td>
<td class=grid2 align=center >".$games."</td>
<td class=grid2 align=center >".$goals."</td>
<td class=grid2 align=center >".$assists."</td>
<td class=grid2 align=center >".$manofthematch."</td>

<td class=grid3 align=center >".$points."</td>

</tr>\n\n"); 


etc etc

Whilst I can sort the order recalled direct from the table by using
PHP Code:

ORDER BY 'position', 'name' 


(many thanks JdS for correcting my errors)
Is it possible to sort by points although this uses a function to calculate the points?

Once again another clear as mud explaination of my problem. JdS will need wellington boots soon.
  #2  
Old 02-Oct-2003, 08:44
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I am afraid I STILL don't get it. It might help if you post some sample data (off a similar, fictitious table) and tell us how you expect the data to look like.

The 'quotes' I use in my SQL statements are not single quotes; they're called backticks, I think. ` is not the same as '.

So, the example in your post should be :
PHP Code:

ORDER BY `position`, `name`
// NOT...
ORDER BY 'position', 'name' 


Quote:
Note that if the identifier is a restricted word or contains special characters you must always quote it with a ` (backtick) when you use it:
More info about this here: http://www.mysql.com/doc/en/Legal_names.html
 
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting a 2D array c++ mike3340 CPP / C++ Forum 4 15-Dec-2003 13:35
Need C++ help with functions EvilIce CPP / C++ Forum 2 01-Dec-2003 16:04
i/o: set value x (long) before it is used by a function gmn C Programming Language 1 18-Nov-2003 01:12
vector sorting gotnospoon CPP / C++ Forum 0 10-Nov-2003 15:26
[class] 404 search function code jrobbio MySQL / PHP Forum 6 22-Apr-2003 09:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:14.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.