Page 1 of 1

Sorting by number

Posted: Tue Jun 25, 2002 4:40 pm
by Russ
If I wanted to sortby a number, not just the number 1, but all the numbers, how would I do that? action=sortby&char=num ? action=sortby&char=number? action=sortby&char=1,2,3,4,5,6,7,8,9,0?

Posted: Wed Jun 26, 2002 1:45 am
by twigletmac
I'm assuming you have a program that someone else has written which you are trying to edit because things like action=sortby&char=num mean nothing to PHP. Could you explain a bit better what you are trying to achieve please and perhaps paste some of the code that you are trying to do it with.

Mac

Posted: Wed Jun 26, 2002 1:28 pm
by Russ
heres my code, basicly I can sort it by various letters, but numbes, but not just the ones that begin with 1 but all the numbers,

Code: Select all

if($_GETї'action'] == 'sortby')
{

$result = mysql_query("select * FROM interdb WHERE bandname LIKE '".strtoupper($_GETї'char'])."%' ORDER BY bandname ASC LIMIT 5",$db); 
while($myrow = mysql_fetch_array($result))

{
echo ( "<p><b><a href=?action=view&id=" .$myrow&#1111;id]. " class=link>" . $myrow&#1111;'bandname'] . "</a></b> <font class=rm>- " . date("F j", strtotime($myrow&#1111;'date'])) . "</font>" );
echo ( "<br>" . $myrow&#1111;'preinter'] );
echo ( "<br><b><font class=rm><a href=?action=view&id=" .$myrow&#1111;id]. " class=rm>...Read More</a></b></font>" );
&#125;


&#125; 

elseif($_GET&#1111;'action'] == 'view') 

&#123;

$result = mysql_query("SELECT * FROM interdb WHERE id=$id",$db); 
$myrow = mysql_fetch_array($result); 

&#123;
echo( "<br><b>" . $myrow&#1111;'bandname'] . " Interview</b>"  );
echo( "<p>" . $myrow&#1111;'preinter'] );
echo( "<p>" . $myrow&#1111;'inter'] );
&#125;

&#125; 

else 

&#123;

$result = mysql_query("SELECT * FROM interdb ORDER BY id desc LIMIT 5",$db); 
while($myrow = mysql_fetch_array($result))

&#123;
echo( "<p><b><a href=?action=view&id=" .$myrow&#1111;id]. " class=link>" . $myrow&#1111;'bandname'] . "</a></b> <font class=rm>- " . date("F j", strtotime($myrow&#1111;'date'])) . "</font>" );
echo( "<br>" . $myrow&#1111;'preinter'] );
echo( "<br><b><font class=rm><a href=?action=view&id=" .$myrow&#1111;id]. " class=rm>...Read More</a></b></font>" );
&#125;

&#125;