You are here: Re: Ranking function in PHP/MySQL « PHP Programming Language « IT news, forums, messages
Re: Ranking function in PHP/MySQL

Posted by Shelly on 10/07/07 11:55

"macca" <ptmcnally@googlemail.com> wrote in message
news:1191735363.893427.245710@g4g2000hsf.googlegroups.com...
> Just to insert some php in here to satisfy the die hards, in order to
> display your ranking order you could do this:
>
> $sql = "SELECT casualtyID, deathdate FROM the_table ORDER BY deathdate
> ASC";
>
> $result = mysql_query($sql,$connection) or die(mysql_error());
>
> for ($i=0; $i < mysql_num_rows($result); $i++){
>
> $casualtyID = mysql_result($result,$i,"casualtyID");
> $death_date = mysql_result($result,$i,"deathdate");
> $rank = $i+=1;
>
> echo "$casualtyID is the number $rank casualty to die in the current
> wars in Iraq and Afghanistan\n";
>
> }

Thanks, macca. I could have added that as well (and maybe then Jerry would
have shut up), but I wanted to leave **something** for the OP to do after I
put him/her on the right track. (BTW, I think you have a typo and meant
$i+1 and not $i+=1)

Shelly

Shelly

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация