khan kaka Posted November 28, 2005 Share Posted November 28, 2005 how can number my search result like yahoo. if my search returns 50 result i want to be bale to place a number next to it . such as 1 -- test result 2 - test reult any dream weaver extentions that can solve this problem? thanks Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/ Share on other sites More sharing options...
ryanlwh Posted November 28, 2005 Share Posted November 28, 2005 if you're using a loop to return the result, then it's easy $num=0; while($row=mysql_fetch_array($result)) { echo $num; /* do stuff */ $num++; } Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/#findComment-9923 Share on other sites More sharing options...
khan kaka Posted November 28, 2005 Author Share Posted November 28, 2005 [!--quoteo(post=322869:date=Nov 28 2005, 04:26 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Nov 28 2005, 04:26 PM) 322869[/snapback][/div][div class=\'quotemain\'][!--quotec--] if you're using a loop to return the result, then it's easy $num=0; while($row=mysql_fetch_array($result)) { echo $num; /* do stuff */ $num++; } ------------------------------------------------------------------------------------------------------------------- Hi there its not working properly or i am doing some thing wrong. i am using rpeated region server behaviour in dream weaver 8. i placed the code it works but the problem is it will only loop the number. and it doese it in the same box it returns 1234 ... 50 in the same row and my data displays only one row. this is the code. <td>phone</td> <td>mobile</td> </tr> <?php do { ?> <tr> <td><?php $num=0; while($row=mysql_fetch_array($listatoz)) { echo $num; /* do stuff */ $num++; } ?></td> <td></td> <td><?php echo $row_listatoz['name']; ?></td> <td><?php echo $row_listatoz['address']; ?></td> <td><?php echo $row_listatoz['city']; ?></td> <td><?php echo $row_listatoz['state']; ?></td> <td><?php echo $row_listatoz['postcode']; ?></td> <td><?php echo $row_listatoz['phone']; ?></td> <td><?php echo $row_listatoz['mobile']; ?></td> </tr> <?php } while ($row_listatoz = mysql_fetch_assoc($listatoz)); ?> </table> </body> </html> <?php mysql_free_result($listatoz); ?> thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/#findComment-9926 Share on other sites More sharing options...
ChrisDarl Posted November 30, 2005 Share Posted November 30, 2005 Believe this should work... you but the code within your loop for calling the mysql data. Not a seperate loop inside the loop? If you get what i mean :S Anyway, give it a try, let me know if it doesnt work and ill test it out n sort it for ya Chris <td>phone</td> <td>mobile</td> </tr> <?php $num = 1; do { ?> <tr> <td><?php echo $num; ?></td> <td></td> <td><?php echo $row_listatoz['name']; ?></td> <td><?php echo $row_listatoz['address']; ?></td> <td><?php echo $row_listatoz['city']; ?></td> <td><?php echo $row_listatoz['state']; ?></td> <td><?php echo $row_listatoz['postcode']; ?></td> <td><?php echo $row_listatoz['phone']; ?></td> <td><?php echo $row_listatoz['mobile']; ?></td> <?php $num++; ?> </tr> <?php } while ($row_listatoz = mysql_fetch_assoc($listatoz)); ?> </table> </body> </html> <?php mysql_free_result($listatoz); ?> Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/#findComment-9956 Share on other sites More sharing options...
khan kaka Posted November 30, 2005 Author Share Posted November 30, 2005 [!--quoteo(post=323288:date=Nov 30 2005, 10:03 AM:name=ChrisDarl)--][div class=\'quotetop\']QUOTE(ChrisDarl @ Nov 30 2005, 10:03 AM) 323288[/snapback][/div][div class=\'quotemain\'][!--quotec--] Believe this should work... you but the code within your loop for calling the mysql data. Not a seperate loop inside the loop? If you get what i mean :S Anyway, give it a try, let me know if it doesnt work and ill test it out n sort it for ya Chris <td>phone</td> <td>mobile</td> </tr> <?php $num = 1; do { ?> <tr> <td><?php echo $num; ?></td> <td></td> <td><?php echo $row_listatoz['name']; ?></td> <td><?php echo $row_listatoz['address']; ?></td> <td><?php echo $row_listatoz['city']; ?></td> <td><?php echo $row_listatoz['state']; ?></td> <td><?php echo $row_listatoz['postcode']; ?></td> <td><?php echo $row_listatoz['phone']; ?></td> <td><?php echo $row_listatoz['mobile']; ?></td> <?php $num++; ?> </tr> <?php } while ($row_listatoz = mysql_fetch_assoc($listatoz)); ?> </table> </body> </html> <?php mysql_free_result($listatoz); ?> Hi Chris thanks for your help it worked but the problem was if i had 100 records and i displayed only 20 per page and when i click next page. on the next page it starts agin from 1 where is should start from 20. i found a solution for it if i place this code outside loop it works fine and starts the new page from 20 or what ever the number should be. <td>phone</td> <td>mobile</td> <?php isset($startRow_listatoz)? $orderNum=$startRow_listatoz:$orderNum=0;?> </tr> <?php do { ?> <tr> <td><?php echo ++$orderNum; ?></td> <td></td> <td><?php echo $row_listatoz['name']; ?></td> <td><?php echo $row_listatoz['address']; ?></td> <td><?php echo $row_listatoz['city']; ?></td> <td><?php echo $row_listatoz['state']; ?></td> <td><?php echo $row_listatoz['postcode']; ?></td> <td><?php echo $row_listatoz['phone']; ?></td> <td><?php echo $row_listatoz['mobile']; ?></td> </tr> <?php } while ($row_listatoz = mysql_fetch_assoc($listatoz)); ?> </table> </body> </html> <?php mysql_free_result($listatoz); ?> once agin thanks for your hlep. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/#findComment-9963 Share on other sites More sharing options...
ChrisDarl Posted December 1, 2005 Share Posted December 1, 2005 You're welcome, so it's all working now right? Chris Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/#findComment-9974 Share on other sites More sharing options...
Taro Posted December 4, 2005 Share Posted December 4, 2005 [!--quoteo(post=323462:date=Nov 30 2005, 05:27 PM:name=khan kaka)--][div class=\'quotetop\']QUOTE(khan kaka @ Nov 30 2005, 05:27 PM) 323462[/snapback][/div][div class=\'quotemain\'][!--quotec--] thanks for your help it worked but the problem was if i had 100 records and i displayed only 20 per page and when i click next page. on the next page it starts agin from 1 where is should start from 20. i found a solution for it if i place this code outside loop it works fine and starts the new page from 20 or what ever the number should be. ooo this is one i can help with! All you do is wherever you have your "next page" link, add a get var "xxx.php?s=20" and then do something like this... //from xxx.php?s=20 if(isset($_GET["s"])) { $s = $_GET["s"]; } else { $s = 0; } $e = $s+20 //add this to your query like so $sql = "SELECT * FROM `table` ORDER BY `field` DESC LIMIT $s, $e"; //the LIMIT clause is the key there, the first number is the entry number to begin displaying by //the second is where to stop. Quote Link to comment https://forums.phpfreaks.com/topic/2947-numbering-the-search-result/#findComment-10008 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.