curt22 Posted December 19, 2006 Share Posted December 19, 2006 I'm new to php and mysql and I need to have the results sorted.First its needs to sort by book.then by chapters inside the books.Then by verse.For example:if its like this now:id testimate book chapter verse1 old genesis 1 12 old Exodus 2 13 old genesis 2 2it would look like this after being sorted:1 old genesis 1 23 old genesis 2 22 old Exodus 2 1the code im using to show the databse is:<?phpinclude 'connect.php';$sql = 'SELECT * FROM bible WHERE MATCH($_post[\'field\'])' . ' AGAINST(\'$_post[\'find\']\' IN BOOLEAN MODE) LIMIT 0, 30 ';$result = mysql_query($sql) or die(mysql_error());while($row = mysql_fetch_array($result)){echo $row['testimate'] . " " . $row['book'] . " " . $row['chapter'] . " " . $row['verse'];echo "<br/>";} ?> ??? ??? ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/31176-solved-sorting-information-in-php-and-mysql/ Share on other sites More sharing options...
fenway Posted December 19, 2006 Share Posted December 19, 2006 No reason your can using multiple fields in the order by clause -- but you'll have fun with the book unless there's a bookid somewhere with a sortorder, or you hard-code the desired order. Link to comment https://forums.phpfreaks.com/topic/31176-solved-sorting-information-in-php-and-mysql/#findComment-144106 Share on other sites More sharing options...
curt22 Posted December 19, 2006 Author Share Posted December 19, 2006 Ok i will make a bookid. And i know how to order things but how do i order them the second time. I could get them to order by book but how i get them to order by chapter inside the book then the verse. ??? Link to comment https://forums.phpfreaks.com/topic/31176-solved-sorting-information-in-php-and-mysql/#findComment-144755 Share on other sites More sharing options...
fenway Posted December 19, 2006 Share Posted December 19, 2006 Add each column you wanted sorted in seqeuence. Link to comment https://forums.phpfreaks.com/topic/31176-solved-sorting-information-in-php-and-mysql/#findComment-144795 Share on other sites More sharing options...
curt22 Posted December 20, 2006 Author Share Posted December 20, 2006 Ok this is as much as i can get could you please tell me what to do with it?<?phpinclude 'connect.php';$query = "SELECT * FROM bible ORDER BY bookid"; $result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){echo $row['testimate'] . " " . $row['book'] . " " . $row['chapter'] . " " . $row['verse'] . " " . $row['verse text'];echo "<br/>";}?> Link to comment https://forums.phpfreaks.com/topic/31176-solved-sorting-information-in-php-and-mysql/#findComment-144853 Share on other sites More sharing options...
fenway Posted December 20, 2006 Share Posted December 20, 2006 Add ORDER BY bookid, chapter, verse. Link to comment https://forums.phpfreaks.com/topic/31176-solved-sorting-information-in-php-and-mysql/#findComment-145307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.