Jump to content

Easy Pagination?


Nightseer

Recommended Posts

Is there an easy way to do pagination? I have now tried every tutorial I can find and still getting some of the most aggravating errors............and of course, it just didn't work. Anyway, the code below is the function that needs it-if you can help, or point in correct direction, it would be GREATLY appreciated ???

[code]<?
function market($breed, $gender)
{

$loop = mysql_query("SELECT * FROM dogs WHERE sellprice > 0 ORDER BY sellprice") or die ('cannot select dogs for sale');
$count = mysql_num_rows($loop);
$i = 1;
$cols = 2;
while ($row = mysql_fetch_array($loop))
{
$dogid = $row['dogid'];
$name = getName($dogid);
$breed = getBreed($row['breed']);
$age = getAge($dogid);
$price = getSalePrice($row['sellprice']);
if($i == 1){
echo "<tr>";
}
echo "
<td align=\"left\" valign=\"top\" width=\"50%\"><br><a href=dog.php?dogid=$dogid>$name</a>, $breed $age $price" . "</td>";
if($i == $cols){
echo "</tr>";
$i = 1;
}
else{
$i++;
}
}
}//end while
?>[/code]
Link to comment
Share on other sites

You can't just echo <a href=dog.php?dogid=$dogid>
Part of it is html and other part is php. Like $dogid has no value in html

Switching back and forth between html and php goes something like this:

[code]echo "<a href=dog.php?dogid=" . $dogid . "more html code";[/code]

Hope this helps.

Also here's a nice tutorial for paging
[url=http://www.phpnoise.com/tutorials/9/1]http://www.phpnoise.com/tutorials/9/1[/url]

Link to comment
Share on other sites

[quote author=intrik link=topic=110073.msg444247#msg444247 date=1159629440]
[quote author=speedy33417 link=topic=110073.msg444219#msg444219 date=1159624279]
You can't just echo <a href=dog.php?dogid=$dogid>
[/quote]

Yeah you can, I do it all the time.
[code]
<?php
echo"<a href='page.php?a=$var'>";
?>
[/code]
[/quote]

Speedy,

To explain a little further, and hopefully be a little more helpful than the previous post...  When using double quoted strings " " the variable is read and the value of it is output.  This is not true of single quoted strings ' '.  So:

[code]<?php
$name = "HuggieBear";

echo "My name is $name"; // Prints My name is HuggieBear

echo 'My name is $name'; // Prints My name is $name
?>
[/code]

I hope this helps.
Regards
Huggie
Link to comment
Share on other sites

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.