Jump to content

Recommended Posts

[!--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

 

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

?>

 

 

[!--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

 

 

 

 

[!--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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.