Pagination with do..while loop

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
telnz
Forum Newbie
Posts: 2
Joined: Thu Aug 05, 2004 11:56 pm
Location: Auckland New Zealand

Pagination with do..while loop

Post by telnz »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I am relitively new to php and I have a task to add pagination to this results page of actors category search . Try as I may I cant seem to intergrate the page snippets into the code . Can anyone help . Here is the page it uses the do..while loop to get the results . I think this may be the problem

Code: Select all

<?php 

require_once('dbconn.php');


$sex=$_POST['sex'];
$hair=$_POST['hair'];
$eyes=$_POST['eyes'];
$look=$_POST['look'];
$location=$_POST['location'];
$minAge=$_POST['minAge'];
$maxAge=$_POST['maxAge'];
$minheight=$_POST['minheight'];
$maxheight=$_POST['maxheight'];


mysql_select_db($database_dbconn, $dbconn);
$sql= "SELECT * FROM actors where act_id >'0' ";

if (isset($_POST['actor'])){ $sql.="&& actor ='yes' "; }
if (isset($_POST['presenter'])){ $sql.="&& presenter ='yes' "; }
if (isset($_POST['dancer'])){ $sql.="&& dancer = 'yes' "; }
if (isset($_POST['singer'])){ $sql.="&& singer = 'yes' "; }
if (isset($_POST['voiceover'])){ $sql.="&& voiceover ='yes' "; }


if ((isset($sex))&&($sex!='-')){ $sql.="&& sex = '".$sex."' "; }

if ((isset($hair))&&($hair!='-')){ $sql.="&& hair = '".$hair."' "; }


if ((isset($look))&&($look!='-')){ $sql.="&& look = '".$look."' "; }

if ((isset($eyes))&&($eyes!='-')){ $sql.="&& eyes = '".$eyes."' "; }

if ((isset($location))&&($location!='-')){ $sql.="&& location = '".$location."' "; }


if (!empty($minAge)){ $sql.="&& minAge <= '".$minAge."'"; }


if (!empty($_POST['maxAge'])){ $sql.="&& maxAge >= '".$_POST['maxAge']."'"; }


if (!empty($minheight)){ $sql.="&& height >= '".$minheight."'"; }


if (!empty($_POST['maxheight'])){ $sql.="&& height <= '".$_POST['maxheight']."'"; }





$actors=mysql_query($sql,$dbconn) or die(mysql_error());
$row_actors=mysql_fetch_assoc($actors);
$totalRows_Actors = mysql_num_rows($actors);



do {



{
echo '<a href="details.php?act_id='.$row_actors['act_id'].'" target="_blank">';
}
echo '<img border="0" width="63" height="90" alt="'.$row_actors['firstname']."&nbsp;".$row_actors['surname'].'"" src=update_folder/photoTH/'.$row_actors['photoTH'].'>';

{
	echo '</a>';
}


} while ($row_actors=mysql_fetch_assoc($actors));


?>

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Post by litebearer »

User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

telnz
Forum Newbie
Posts: 2
Joined: Thu Aug 05, 2004 11:56 pm
Location: Auckland New Zealand

Post by telnz »

thanks people I will work my way through both tutorials they look good.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Yes they sure are :D you can do a search on google for "PHP pagination tutorial".
Post Reply