Nightseer Posted September 30, 2006 Share Posted September 30, 2006 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 https://forums.phpfreaks.com/topic/22591-easy-pagination/ Share on other sites More sharing options...
speedy33417 Posted September 30, 2006 Share Posted September 30, 2006 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 htmlSwitching 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 https://forums.phpfreaks.com/topic/22591-easy-pagination/#findComment-101363 Share on other sites More sharing options...
Nightseer Posted September 30, 2006 Author Share Posted September 30, 2006 Um-that code seems to be working fine?Was needing a way to make it list on more than one page..... Link to comment https://forums.phpfreaks.com/topic/22591-easy-pagination/#findComment-101364 Share on other sites More sharing options...
speedy33417 Posted September 30, 2006 Share Posted September 30, 2006 Not to mention that you're missing a " sign around your href.[code]<a href"=dog.php?dogid=something">[/code]Also you said:Um-that code seems to be working fine?Are you asking or saying? Link to comment https://forums.phpfreaks.com/topic/22591-easy-pagination/#findComment-101375 Share on other sites More sharing options...
Nightseer Posted September 30, 2006 Author Share Posted September 30, 2006 No-it lists the dogs correctly-lol-though that solved another list problem I was working on. I'm not sure WHY that one lists correctly-but it does.... Link to comment https://forums.phpfreaks.com/topic/22591-easy-pagination/#findComment-101378 Share on other sites More sharing options...
intrik Posted September 30, 2006 Share Posted September 30, 2006 [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]<?phpecho"<a href='page.php?a=$var'>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/22591-easy-pagination/#findComment-101390 Share on other sites More sharing options...
HuggieBear Posted October 1, 2006 Share Posted October 1, 2006 [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]<?phpecho"<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 HuggieBearecho 'My name is $name'; // Prints My name is $name?>[/code]I hope this helps.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/22591-easy-pagination/#findComment-101797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.