Jump to content


Photo

numbering the search result


  • Please log in to reply
6 replies to this topic

#1 khan kaka

khan kaka
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts
  • Locationaustralia

Posted 28 November 2005 - 06:12 AM


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


khan kaka

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 28 November 2005 - 09:26 PM

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++;
}

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#3 khan kaka

khan kaka
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts
  • Locationaustralia

Posted 28 November 2005 - 11:09 PM

[!--quoteo(post=322869:date=Nov 28 2005, 04:26 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Nov 28 2005, 04:26 PM) View Post[/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++;
}
[/quote]

-------------------------------------------------------------------------------------------------------------------

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

khan kaka

#4 ChrisDarl

ChrisDarl
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 30 November 2005 - 03:03 PM

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);
?>



#5 khan kaka

khan kaka
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts
  • Locationaustralia

Posted 30 November 2005 - 09:27 PM

[!--quoteo(post=323288:date=Nov 30 2005, 10:03 AM:name=ChrisDarl)--][div class=\'quotetop\']QUOTE(ChrisDarl @ Nov 30 2005, 10:03 AM) View Post[/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);
?>
[/quote]

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




khan kaka

#6 ChrisDarl

ChrisDarl
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 01 December 2005 - 01:45 PM

You're welcome, so it's all working now right?

Chris

#7 Taro

Taro
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 December 2005 - 06:49 AM

[!--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) View Post[/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.
[/quote]
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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users