![]() |
|
? |
![]() PHP FAQ PHP Articles PHP Help Bulletin Board PHP Manual (NEW!) First Time PHP'ers Help with programming Sql assignment help PHP Homework Help C# Help
|
? |
|
|||||||||||||||
?Reply To This Message | ||||||||||||||||||
?Your Name: | ||||||||||||||||||
?Your Email: | ||||||||||||||||||
?Subject: | ||||||||||||||||||
|
||||||||||||||||||
Email replies to this thread, to the address above. | ||||||||||||||||||
??wrote: > > Greetings, > > Does anyone know how to properly use natsort on result from a > query? I have searched hi and low and can only find a > reference to it in the php manual. What I'm trying to figure > out is how to natural sort a table from a mysql query. Here > is some code I'm working with: > > require($DOCUMENT_ROOT . "/siteplans/inc/siteplans_db.inc"); > > $table_name=$phasenumber; > $lot_sql="SELECT lot_number FROM $table_name WHERE > availability LIKE 'For Sale' OR availability LIKE 'Re-listed' > ORDER BY lot_number ASC LIMIT 0,17"; > > $result=mysql_db_query($data_base, $lot_sql, $conn); > $array_lot_number = array(); > while ($row = mysql_fetch_array($result)) { > $array_temp = array($row[0]); > $array_lot_number = array_merge($array_lot_number, > $array_temp); > } > > // sorting on natural algorithm > $array_lot_number = natsort($array_lot_number); > > // set pointer to first entry > reset ($array_lot_number); > > while (list ($key, $val) = each ($array_lot_number)) { > > ?> > > echo $key; > echo $val; > } > ?> > > Here are the two errors I'm getting: > 1) Variable passed to reset() is not an array or object > 2) Variable passed to each() is not an array or object > > Does anyone know a better way of doing this? or know what I'm > doing wrong? > > thanks ">??![]() |