/    Sign up×
Community /Pin to ProfileBookmark

Problem with advanced search pagination

Hi can somebody help me with this pagination coding.I have use this pagination to display searched items. it searches and display 1-2 items. but once i click the next link it doesn’t display anything.i know where the problem is.here it is

$link = “search.php?page_no={$page_no}”;

please try to solove it.
thanks

<?php

/* ======== search.php ======= */

@$advance_search = advance_search($_POST[‘condition’],$_POST[‘make’],$_POST[‘model’],$_POST[‘year’],$_POST[‘fuel_type’],$_POST[‘trans’],$_POST[‘price’]);
@$num_of_records = show_count_for_advance_search($_
POST[‘condition’],$_POST[‘make’],$_POST[‘model’],$_POST[‘year’],$_POST[‘fuel_type’],$_POST[‘trans’],$_POST[‘price’]);
$no_of_rows = count($advance_search);

$display_items = 2;

if (!isset($_GET[‘page_no’])){
$start_no = 1;
}
if (@$_GET[‘page_no’] != ”){
if ($_GET[‘page_no’] == 1){
$start_no = $display_items;
}
if ($_GET[‘page_no’] > 1){
$start_no = ($_GET[‘page_no’]) * $display_items;
}
}
if ($num_of_records < $display_items){
$link_message = “Showing 1 to {$num_of_records} of {$num_of_records}”;
@$page_message = “Page ” . (@$_GET[‘page_no’] + 1) . ” of {$no_of_pages}”;
}else{
$no_of_pages = ceil($num_of_records/$display_items);
@$page_no = $_GET[‘page_no’] + 1;

//if ($_GET[‘type’] == ‘advance’){

if ($_POST[‘condition’]!=’0′){
//@$link_concat .= “vehical_condition=”.$_POST[‘condition’];
@$link_concat .= “vehical_condition='”.$_POST[‘condition’].”‘”;
}
if ($_POST[‘make’]!=’0′){
@$link_concat .= “&vehical_make='”.$_POST[‘make’].”‘”;
}
if ($_POST[‘model’]!=’0′){
@$link_concat .= “&vehical_model='”.$_POST[‘model’].”‘”;
}
if ($_POST[‘year’]!=’0′){
@$link_concat .= “&manifac_year='”.$_POST[‘year’].”‘”;
}
if ($_POST[‘fuel_type’]!=’0′){
@$link_concat .= “&fuel_type='”.$_POST[‘fuel_type’].”‘”;
}
if ($_POST[‘trans’]!=’0′){
@$link_concat .= “&transmission='”.$_POST[‘trans’].”‘”;
}
if ($_POST[‘price’]!=’0′){
@$link_concat .= “&price='”.$_POST[‘price’].”‘”;
}

/*problem comes here*/ $link = “search.php?page_no={$page_no}”;

$set_pages = $page_no * $display_items;
$remain_items = $num_of_records – $set_pages;
$condition = ($page_no + 1) * $display_items;

if($condition < @$tot_itmes){
$nextLink=”<a href = $link class =’industry_pag_links’>Next Page &gt;</a>”;
}
if ($remain_items > 0){
$nextLink=”<a href = $link class =’industry_pag_links’>Next Page &gt;</a>”;
if ($remain_items < $display_items){
$end_no_remain = $page_no * $display_items;
}else{
$end_no_remain = $page_no * $display_items;
}
}
if ($remain_items <= 0){
$end_no_remain = $num_of_records;
}
if ($remain_items == $num_of_records){
$end_no_remain = $remain_items;
}

if(@$_GET[‘page_no’]==0){
$start_no = ‘1’;
}
if(@$_GET[‘page_no’] > 0){
$page_no = $_GET[‘page_no’]-1;

$linkPrivous = “search.php?$link_concat&page_no={$page_no}”;
$previous = ‘previous’;
$previousLink = “<a href = $linkPrivous class=’industry_pag_links’>&lt; Previous</a>”;
}
@$link_message = “$previousLink Displaying $start_no to $end_no_remain of $num_of_records $nextLink”;
@$page_message = “Page ” . (@$_GET[‘page_no’] + 1) . ” of {$no_of_pages}”;
}

if($no_of_rows > 0){
// pagination display
echo “<div align=’center’>”;
if ($num_of_records > 0){
echo $link_message;
}
echo “</div>”;
echo “<br />”;
// end of pagination display
for ($i=0; $i<$no_of_rows; $i++){

echo “<div id=’results’>”;
// display results in a table
echo “<table border=’1′ bordercolor=’#3399CC’ cellspacing=’0′ width=’500′ height=’163′>”;
?>
<tr>
<td width=”26%” height=”33″>&nbsp;</td>
<td width=”18%”><?php echo $advance_search[$i][‘vehical_make’]; ?></td>
<td width=”20%”><?php echo $advance_search[$i][‘vehical_model’]; ?></td>
<td colspan=”2″>2009/03/04 12:25:30</td>
</tr>
<tr>
<?php echo “<tr><td rowspan=’3′><img src=”car_display_create.php?vehical_id=”.$advance_search[$i][‘vehical_id’].”” width=”100″ height=”100″></td>”; ?>
<!–<td rowspan=”3″><img src=”car_display_create.php?vehical_id=”.$view_users[$i][‘vehical_id’].”” width=”100″ height=”100″></td> –>
<td height=”49″>Condition</td>
<td><?php echo $advance_search[$i][‘vehical_condition’]; ?></td>
<td width=”19%”>Transmission</td>
<td width=”17%”><?php echo $advance_search[$i][‘transmission’]; ?></td>
</tr>
<tr>
<td height=”45″>Year</td>
<td><?php echo $advance_search[$i][‘manifac_year’]; ?></td>
<td>Fuel Type</td>
<td><?php echo $advance_search[$i][‘fuel_type’]; ?></td>
</tr>
<tr>
<td rowspan=”2″>Engine Capacity</td>
<td rowspan=”2″><?php echo $advance_search[$i][‘engine_capa’]; ?></td>
<td rowspan=”2″>Price</td>
<td rowspan=”2″><?php echo $advance_search[$i][‘price’]; ?></td>
</tr>
<tr>
<?php echo “<td height=”27″><a href=”car_display.php?task=1 & vehical_id=”.$advance_search[$i][‘vehical_id’].””>View Full Details</a></td></tr>”; ?>

<!– <td height=”27″><a href=”car_display.php?task=1″>Click here to view details</a></td> –>

</tr>

<?php

echo “</table>n”;
echo “</div>”;
echo “<br>”;

}
}

// pagination display
echo “<div align=’center’>”;
if ($num_of_records > 0){
echo $link_message;
}
echo “</div>”;
// end of pagination display

?>

function advance_search($cond,$make,$model,$year,$fuel_type,$trans,$price)
{

global $connection;

$display_items = 2;

@$page_no = $_GET[‘page_no’];

if (isset($_GET[‘page_no’])){
if ($_GET[‘page_no’] != ”){
if ($_GET[‘page_no’] == 0){
$start_no_sql = 0;
$end_no_sql = $display_items;
}else{
$start_no_sql = $page_no * $display_items;
$end_no_sql = $display_items;
}
}
}else{
$start_no_sql = 0;
$end_no_sql = $display_items;
}
$limit = ” Limit {$start_no_sql}, {$end_no_sql}”;

$sql = “Select * From vehicals where”;
if ($cond != ‘0’)
{
$sql .= ” vehical_condition = ‘”.$cond.”‘”;

if(($make!=”0″) || ($model!=”0″) || ($year!=”0″) || ($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($make != ‘0’)
{
$sql .= ” vehical_make = ‘”.$make.”‘”;
if(($model!=”0″) || ($year!=”0″) || ($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($model != ‘0’)
{
$sql .= ” vehical_model = ‘”.$model.”‘”;
if(($year!=”0″) || ($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($year != ‘0’)
{
$sql .= ” manifac_year = ‘”.$year.”‘”;
if(($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($fuel_type != ‘0’)
{
$sql .= ” fuel_type = ‘”.$fuel_type.”‘”;
if(($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($trans != ‘0’)
{
$sql .= ” transmission = ‘”.$trans.”‘”;
if(($price!=”0″))
{
$sql.=” and “;
}

}
if ($price != ‘0’)
{
$sql .= ” price = ‘”.$price.”‘”;

}

$sql .= $limit;
//die($sql);
$results = mysql_query($sql,$connection);

if ($results)
{

$i = 0;
$advance_search = array();
while ($row = mysql_fetch_array($results)){
$advance_search[$i][‘vehical_id’] = $row[‘vehical_id’];
$advance_search[$i][‘vehical_condition’] = $row[‘vehical_condition’];
$advance_search[$i][‘vehical_make’] = $row[‘vehical_make’];
$advance_search[$i][‘vehical_model’] = $row[‘vehical_model’];
$advance_search[$i][‘manifac_year’] = $row[‘manifac_year’];
$advance_search[$i][‘fuel_type’] = $row[‘fuel_type’];
$advance_search[$i][‘transmission’] = $row[‘transmission’];
$advance_search[$i][‘engine_capa’] = $row[‘engine_capa’];
$advance_search[$i][‘price’] = $row[‘price’];
$i++;
}
return $advance_search;
}

}

function show_count_for_advance_search($cond,$make,$model,$year,$fuel_type,$trans,$price)
{

global $connection;

$sql = “Select * From vehicals where”;
if ($cond != ‘0’)
{
$sql .= ” vehical_condition = ‘”.$cond.”‘”;

if(($make!=”0″) || ($model!=”0″) || ($year!=”0″) || ($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($make != ‘0’)
{
$sql .= ” vehical_make = ‘”.$make.”‘”;
if(($model!=”0″) || ($year!=”0″) || ($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($model != ‘0’)
{
$sql .= ” vehical_model = ‘”.$model.”‘”;
if(($year!=”0″) || ($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($year != ‘0’)
{
$sql .= ” manifac_year = ‘”.$year.”‘”;
if(($fuel_type!=”0″) || ($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($fuel_type != ‘0’)
{
$sql .= ” fuel_type = ‘”.$fuel_type.”‘”;
if(($trans!=”0″) || ($price!=”0″))
{
$sql.=” and “;
}

}
if ($trans != ‘0’)
{
$sql .= ” transmission = ‘”.$trans.”‘”;
if(($price!=”0″))
{
$sql.=” and “;
}

}
if ($price != ‘0’)
{
$sql .= ” price = ‘”.$price.”‘”;

}

if ($results = mysql_query($sql,$connection))
{
$num_of_records = mysql_num_rows($results);
return $num_of_records;
}

}

/* === end of searh.php === */

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@TecBratMar 05.2009 — If you'll notice at the top of the forum post box, there is an icon of a piece of paper with "php" written on it. If you'll click that, and paste your code between the tags it creates it will make it easier for everyone to read.
Copy linkTweet thisAlerts:
@TecBratMar 06.2009 — In this section of code:[code=php]if (!isset($_GET['page_no'])){
$start_no = 1;
}
if (@$_GET['page_no'] != ''){
if ($_GET['page_no'] == 1){
$start_no = $display_items;
}
if ($_GET['page_no'] > 1){
$start_no = ($_GET['page_no']) * $display_items;
}
}
[/code]

The variable name "start_no" would make me think you want the first item on the page, but the logic tells me that you want that variable to be the last item on the page. Is that what you intended?

Also, why so many error supressions?
Copy linkTweet thisAlerts:
@sodaauthorMar 06.2009 — Thanks. i have written as u have told.Actually i have written the function advance_search & show_count_for_advance_search in a seperate php page.is there any possibility for me to attach those file to this forum. Or else if u have any better pagination coding that works with advanced search please let me know.

thanks

soda


[code=php]<?php

/* ======== search.php ======= */


@$advance_search = advance_search($_POST['condition'],$_POST['make'],$_POST['model'],$_POST['year'],$_POST['fuel_type'],$_POST['trans'],$_POST['price']);
@$num_of_records = show_count_for_advance_search($_POST['condition'],$_POST['make'],$_POST['model'],$_POST['year'],$_POST['fuel_type'],$_POST['trans'],$_POST['price']);
$no_of_rows = count($advance_search);

$display_items = 2;

if (!isset($_GET['page_no'])){
$start_no = 1;
}
if (@$_GET['page_no'] != ''){
if ($_GET['page_no'] == 1){
$start_no = $display_items;
}
if ($_GET['page_no'] > 1){
$start_no = ($_GET['page_no']) * $display_items;
}
}
if ($num_of_records < $display_items){
$link_message = "Showing 1 to {$num_of_records} of {$num_of_records}";
@$page_message = "Page " . (@$_GET['page_no'] + 1) . " of {$no_of_pages}";
}else{
$no_of_pages = ceil($num_of_records/$display_items);
@$page_no = $_GET['page_no'] + 1;


//if ($_GET['type'] == 'advance'){

if ($_POST['condition']!='0'){
//@$link_concat .= "vehical_condition=".$_POST['condition'];
@$link_concat .= "vehical_condition='".$_POST['condition']."'";
}
if ($_POST['make']!='0'){
@$link_concat .= "&vehical_make='".$_POST['make']."'";
}
if ($_POST['model']!='0'){
@$link_concat .= "&vehical_model='".$_POST['model']."'";
}
if ($_POST['year']!='0'){
@$link_concat .= "&manifac_year='".$_POST['year']."'";
}
if ($_POST['fuel_type']!='0'){
@$link_concat .= "&fuel_type='".$_POST['fuel_type']."'";
}
if ($_POST['trans']!='0'){
@$link_concat .= "&transmission='".$_POST['trans']."'";
}
if ($_POST['price']!='0'){
@$link_concat .= "&price='".$_POST['price']."'";
}

/*problem comes here*/ $link = "search.php?page_no={$page_no}";

$set_pages = $page_no * $display_items;
$remain_items = $num_of_records - $set_pages;
$condition = ($page_no + 1) * $display_items;

if($condition < @$tot_itmes){
$nextLink="<a href = $link class ='industry_pag_links'>Next Page &gt;</a>";
}
if ($remain_items > 0){
$nextLink="<a href = $link class ='industry_pag_links'>Next Page &gt;</a>";
if ($remain_items < $display_items){
$end_no_remain = $page_no * $display_items;
}else{
$end_no_remain = $page_no * $display_items;
}
}
if ($remain_items <= 0){
$end_no_remain = $num_of_records;
}
if ($remain_items == $num_of_records){
$end_no_remain = $remain_items;
}

if(@$_GET['page_no']==0){
$start_no = '1';
}
if(@$_GET['page_no'] > 0){
$page_no = $_GET['page_no']-1;

$linkPrivous = "search.php?$link_concat&page_no={$page_no}";
$previous = 'previous';
$previousLink = "<a href = $linkPrivous class='industry_pag_links'>&lt; Previous</a>";
}
@$link_message = "$previousLink Displaying $start_no to $end_no_remain of $num_of_records $nextLink";
@$page_message = "Page " . (@$_GET['page_no'] + 1) . " of {$no_of_pages}";
}


if($no_of_rows > 0){
// pagination display
echo "<div align='center'>";
if ($num_of_records > 0){
echo $link_message;
}
echo "</div>";
echo "<br />";
// end of pagination display
for ($i=0; $i<$no_of_rows; $i++){



echo "<div id='results'>";
// display results in a table
echo "<table border='1' bordercolor='#3399CC' cellspacing='0' width='500' height='163'>";
?>
<tr>
<td width="26&#37;" height="33">&nbsp;</td>
<td width="18%"><?php echo $advance_search[$i]['vehical_make']; ?></td>
<td width="20%"><?php echo $advance_search[$i]['vehical_model']; ?></td>
<td colspan="2">2009/03/04 12:25:30</td>
</tr>
<tr>
<?php echo "<tr><td rowspan='3'><img src="car_display_create.php?vehical_id=".$advance_search[$i]['vehical_id']."" width="100" height="100"></td>"; ?>
<!--<td rowspan="3"><img src="car_display_create.php?vehical_id=".$view_users[$i]['vehical_id']."" width="100" height="100"></td> -->
<td height="49">Condition</td>
<td><?php echo $advance_search[$i]['vehical_condition']; ?></td>
<td width="19%">Transmission</td>
<td width="17%"><?php echo $advance_search[$i]['transmission']; ?></td>
</tr>
<tr>
<td height="45">Year</td>
<td><?php echo $advance_search[$i]['manifac_year']; ?></td>
<td>Fuel Type</td>
<td><?php echo $advance_search[$i]['fuel_type']; ?></td>
</tr>
<tr>
<td rowspan="2">Engine Capacity</td>
<td rowspan="2"><?php echo $advance_search[$i]['engine_capa']; ?></td>
<td rowspan="2">Price</td>
<td rowspan="2"><?php echo $advance_search[$i]['price']; ?></td>
</tr>
<tr>
<?php echo "<td height="27"><a href="car_display.php?task=1 & vehical_id=".$advance_search[$i]['vehical_id']."">View Full Details</a></td></tr>"; ?>

<!-- <td height="27"><a href="car_display.php?task=1">Click here to view details</a></td> -->
</tr>

<?php

echo "</table>n";
echo "</div>";
echo "<br>";

}
}

// pagination display
echo "<div align='center'>";
if ($num_of_records > 0){
echo $link_message;
}
echo "</div>";
// end of pagination display

?>






function advance_search($cond,$make,$model,$year,$fuel_type,$trans,$price)
{

global $connection;

$display_items = 2;

@$page_no = $_GET['page_no'];

if (isset($_GET['page_no'])){
if ($_GET['page_no'] != ''){
if ($_GET['page_no'] == 0){
$start_no_sql = 0;
$end_no_sql = $display_items;
}else{
$start_no_sql = $page_no * $display_items;
$end_no_sql = $display_items;
}
}
}else{
$start_no_sql = 0;
$end_no_sql = $display_items;
}
$limit = " Limit {$start_no_sql}, {$end_no_sql}";




$sql = "Select * From vehicals where";
if ($cond != '0')
{
$sql .= " vehical_condition = '".$cond."'";

if(($make!="0") || ($model!="0") || ($year!="0") || ($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($make != '0')
{
$sql .= " vehical_make = '".$make."'";
if(($model!="0") || ($year!="0") || ($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($model != '0')
{
$sql .= " vehical_model = '".$model."'";
if(($year!="0") || ($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($year != '0')
{
$sql .= " manifac_year = '".$year."'";
if(($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($fuel_type != '0')
{
$sql .= " fuel_type = '".$fuel_type."'";
if(($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($trans != '0')
{
$sql .= " transmission = '".$trans."'";
if(($price!="0"))
{
$sql.=" and ";
}

}
if ($price != '0')
{
$sql .= " price = '".$price."'";

}

$sql .= $limit;
//die($sql);
$results = mysql_query($sql,$connection);

if ($results)
{

$i = 0;
$advance_search = array();
while ($row = mysql_fetch_array($results)){
$advance_search[$i]['vehical_id'] = $row['vehical_id'];
$advance_search[$i]['vehical_condition'] = $row['vehical_condition'];
$advance_search[$i]['vehical_make'] = $row['vehical_make'];
$advance_search[$i]['vehical_model'] = $row['vehical_model'];
$advance_search[$i]['manifac_year'] = $row['manifac_year'];
$advance_search[$i]['fuel_type'] = $row['fuel_type'];
$advance_search[$i]['transmission'] = $row['transmission'];
$advance_search[$i]['engine_capa'] = $row['engine_capa'];
$advance_search[$i]['price'] = $row['price'];
$i++;
}
return $advance_search;
}
}


function show_count_for_advance_search($cond,$make,$model,$year,$fuel_type,$trans,$price)
{

global $connection;

$sql = "Select * From vehicals where";
if ($cond != '0')
{
$sql .= " vehical_condition = '".$cond."'";

if(($make!="0") || ($model!="0") || ($year!="0") || ($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($make != '0')
{
$sql .= " vehical_make = '".$make."'";
if(($model!="0") || ($year!="0") || ($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($model != '0')
{
$sql .= " vehical_model = '".$model."'";
if(($year!="0") || ($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($year != '0')
{
$sql .= " manifac_year = '".$year."'";
if(($fuel_type!="0") || ($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($fuel_type != '0')
{
$sql .= " fuel_type = '".$fuel_type."'";
if(($trans!="0") || ($price!="0"))
{
$sql.=" and ";
}

}
if ($trans != '0')
{
$sql .= " transmission = '".$trans."'";
if(($price!="0"))
{
$sql.=" and ";
}

}
if ($price != '0')
{
$sql .= " price = '".$price."'";

}

if ($results = mysql_query($sql,$connection))
{
$num_of_records = mysql_num_rows($results);
return $num_of_records;
}
}










/* === end of searh.php === */ [/code]
Copy linkTweet thisAlerts:
@TecBratMar 06.2009 — Here's some code I use. As indicated in it's comments, I only re-wrote someone else's script. I hope this helps. See the original here:http://www.programmingtalk.com/showthread.php?p=29121

I hope I didn't break anything when I pulled out my private info.
[code=php]<?php
//take care of some variables I am passing to this file
$found_url=stripslashes($found_url);
$found_dirurl=stripslashes($found_dirurl);

//This file is almost entirely borrowed code.
//I found it here: http://www.programmingtalk.com/showthread.php?p=29121
//
// open connection
$conn = mysql_connect(blah blah blah);

// pick database
mysql_select_db("blah",$conn);

// bring out the results of our query and format them in rows *and* columns.

// set the number of results to display on each page
if (!($limit)){
$limit = 10;
}

// check to see if were on the first page of the results
if (!($page)){
$page = 0;
}

// in order to paginate the results we need to know in advance how many there are
$numresults = mysql_query("SELECT * FROM directory WHERE dirurl &lt;&gt; ''");
$numrows = mysql_num_rows($numresults);

// if there are no results, print a friendly message
if ($numrows == 0){
print("&lt;td&gt;No directories were found.&lt;/td&gt;n
&lt;/tr&gt;n&lt;/table&gt;n");
exit();
}

// divide the number of results by the number displayed on each page, to get number of pages
$pages = intval($numrows/$limit);

// if there are results left over, we need to add one more page
if ($numrows%$limit) {
$pages++;
}

$current = ($page/$limit) + 1; // calculate the current page number.

if (($pages &lt; 1) || ($pages == 0)) {
$total = 1;
} else { // if $pages is less than one or equal to 0, total pages equals 1
$total = $pages;
} // if not, total pages is the value of $pages

$first = $page + 1;

//if this is not the last results page, last result = $page plus $limit

if (!((($page + $limit) / $limit) &gt;= $pages) &amp;&amp; $pages != 1) {
$last = $page + $limit;
} else { // if this is the last results page, last result equals total number of results
$last = $numrows;
}

// below here can be changed if you want more or less columns etc
$numcols = 1; // how many columns we want on the page
$numcolsprinted = 0; // how many columns we have so far, do not change!

// get the results to be displayed in this set
$query = "SELECT * FROM directory WHERE dirurl &lt;&gt; '' ORDER BY dirurl ASC LIMIT $page, $limit ";
$result = mysql_query($query, $conn) or die (mysql_error());

// get each row
while ($row = mysql_fetch_array($result)) {

//REDACTED CODE


// we have to check to see if a row has been completed and if it has, start a new one
if ($numcolsprinted == $numcols) {
//print "&lt;/tr&gt;n&lt;tr&gt;n";
$numcolsprinted = 0;
}

// output a row of results with columns evenly spaced

include('display.php'); //contains html to display the results

// increment row counter
$numcolsprinted++;

} // end while loop, at this point we have all the results

// now we need to pad out the table with empty cells if there's a final row with
// fewer results than the number of columns we want to display
$colstobalance = $numcols - $numcolsprinted;

for ($i=1; $i&lt;=$colstobalance; $i++) {
print " &lt;td&gt; &lt;/td&gt;n &lt;/tr&gt;";
}

?&gt;

&lt;tr&gt;
&lt;td colspan="4"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="4"&gt;

&lt;?php
if ($page != 0) { // don
t show back link if this is the first page
$back_page = $page - $limit;
?>
&nbsp;&nbsp;<a href="?page=<? echo ($back_page); ?>&limit=<? echo($limit);?>&form_clienturl=<? echo($found_url);?>">Previous</a>
<?
} else {
print ("&nbsp;&nbsp;&nbsp;&nbsp;");
}

$ppage = $limit*($i - 1);
print ("page $current of $pages");

if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // if this isn't the last page show 'next' link
$next_page = $page + $limit;
?>
&nbsp;&nbsp;<a href="?page=<? echo ($next_page); ?>&limit=<? echo($limit);?>&form_clienturl=<? echo($found_url);?>">Next</a>
<?
} else {
print ("&nbsp;&nbsp;&nbsp;&nbsp;");
}
?>
[/code]
Copy linkTweet thisAlerts:
@sodaauthorMar 07.2009 — Thankx for the coding.I'll try it.

thankx.

soda
×

Success!

Help @soda spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...