Jump to content

Page row


nicklascortez

Recommended Posts

Dear Phpfreaks :D,

 

I still got a problem with my search menu (A) http://www.phpfreaks.com/forums/php-coding-help/search-menu-problem/

 

But i wanna get rid of another problem.

@ http://deltaboatcenter.nl/boat_listing.php?lang=dutch

 

i got 5 boats shown, and 8 pages. but at the bottom of the page i just see pag First < 1. 2. 3.> Last

i wanna get rid of this and just show all the boats at the same page.

 

Some one got a solution, or what i need so look for(php code)

 

Here is the code i use


<?php
include('dbclass/db.php');
include('define.php');
//////////include('pagination.class.php');
include('include/ps_pagination.php');
include_once('classes/easyphpthumbnail.class.php');


$thumb = new easyphpthumbnail;
$thumb -> Thumbheight = 140;
$thumb -> Thumbwidth = 200;
$thumb -> Thumblocation = 'thumb/';
$thumb -> Thumbprefix = 'thumb_';
$thumb -> Thumbsaveas = 'png';

if($lang == 'eng')
{
$header = "header_eng.php";
$footer = "footer_eng.php";
$where = 'language_id=1';
$language =1;
}
elseif($lang == 'dutch')
{
$header = "header_dutch.php";
$footer = "footer_dutch.php";
$where = 'language_id=2';
$language =2;
}
elseif($lang == 'german')
{
$header = "header_german.php";
$footer = "footer_german.php";
$where = 'language_id=3';
$language =3;
}
else
{
$header = "header_eng.php";
$footer = "footer_eng.php";
$where = 'language_id=1';
$language =1;
}

//select query
                       $obj = new Database;
					$obj ->select('english_boats','',$where);


					 $query= "select * from english_boats where language_id=$language";
				   	 $pager = new PS_Pagination($obj->getConnection(),$query,5,3);
                      	 $rs = $pager->paginate();

					/////////var_dump($rs);
					///////exit;
				   $sel= "select * from english_boats";
				  /// $q=mysql_query($sel) or die mysql_error();

				   //generate thumbnail
				 //  include('boat_function.php');


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type='text/javascript' src='jspop/jquery.js'></script>
<script type='text/javascript' src='jspop/jquery.simplemodal.js'></script>
<script type='text/javascript' src='jspop/osx.js'></script>
<script src="prototype.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Delta Boat company boat listing</title>
<link href="boatstyle/boatstyle.css" rel="stylesheet" type="text/css" />
</head>

<body class="background">
<script>
function dosubmit( ) {
  new Ajax.Updater( 'result', 'search_boat.php', { method: 'post',
    parameters: $('myform').serialize() } );
  $('myform').reset();
}

//get_call
function get_call( ) {
if(document.calform.name.value=="")
	    {
		//inlineMsg('name','please enter the name',20);
		 alert('Please enter the name');
		 document.calform.name.focus();
		 return false;
		 }
		 var phone = /-\d{7}/ ;

		 if(!phone.test(document.calform.tel_number.value))
		 {
		 alert('Please enter the telephone number');
		 document.calform.tel_number.focus();
		 return false;
		 }
var aemail= /^[a-z0-9_\+-]+(\.[a-z0-9_\+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,4})$/;

		 if(!aemail.test(document.calform.email.value))
		 {
		 alert('Please enter the valid email address');
		 document.calform.email.focus();
		 return false;
		 }
  new Ajax.Updater( 'get_result', 'make_home_appointment.php', { method: 'post',
    parameters: $('calform').serialize() } );
  $('calform').reset();
}
</script>
<div class="container">
  <?php include($header);
  ?>
  <div class="clear"></div>
  <div class="line"></div>
  <div class="searchPanel">

    <div class="searchTop"></div>
    <div class="clear"></div>
    <div class="searchMid">
      <div class="searchTitle">Search</div>
<div class="searchForm">
<!--javascript:get(document.getElementById('myform'));-->
<form id="myform">
<input type="hidden" name="language" value="<?php echo $language;?>" />

<table class ="textboxAlign" width="100%" border="0">
      <tr>
        <td width="38%" class="searchItem">Brand:</td>
        <td width="62%" class="searchItem"><div class="textboxAlign">
          <select name="brand" id="brand" style="width:140px">
              <option value="any">any</option>
              <?php while($r_b =mysql_fetch_array($q)){ ?>
       <option value="<?php echo $r_b['boat_brand'];?>"><?php echo $r_b['boat_brand'];?></option>
              <?php }?>
              <!--	<option value="brand B">Company B</option>
		<option value="brand C">Company C</option>
		<option value="brand D">Company D</option>-->
                  </select>
        </div></td>
      </tr>
      <tr>
        <td nowrap="nowrap" class="searchItem">Year From:</td>
        <td class="searchItem"><div class="textboxAlign">
  <input type="text" name="year_from" id="year_from" value="any" size="5" onfocus="if(this.value == this.defaultValue) this.value = ''"/>
  To:
  <input type="text" name="year_to" id="year_to" value="any" size="5" onfocus="if(this.value == this.defaultValue) this.value = ''"/>
        </div> </td>
      </tr>
      <tr>
        <td class="searchItem">Price From:</td>
        <td class="searchItem"><div class="textboxAlign">
  <input type="text" name="price_from" id="price_from" value="any" size="5" onfocus="if(this.value == this.defaultValue) this.value = ''"/>
  To:
  <input type="text" name="price_to" id="price_to" value="any" size="5" onfocus="if(this.value == this.defaultValue) this.value = ''"/>
        </div></td></tr>
      <tr>
        <td class="searchItem" valign="top">Features:</td>
        <td nowrap="nowrap" class="searchItem"><input type="checkbox" name="heating" id="heating"  value="588" />           Heating System</td>
      </tr>
      <tr>
        <td> </td>
        <td class="searchItem">
          <input type="checkbox" name="generator" id="generator"  value="661" />
           Generator</td>
      </tr>
   <tr>
        <td> </td>
        <td class="searchItem" align="left">
          <input type="checkbox" name="bow" id="bow_thruster"  value="297" />
           Bow Thruster</td>
      </tr>
   <tr>
        <td> </td>
        <td class="searchItem">
          <input type="checkbox" name="stern" id="stern_thruster"  value="964" />
           Stern Thruster</td>
      </tr>
  <tr>
  <td colspan="2" align="center">
  <input type="button" onclick="dosubmit()" value="Search">
 <!-- <input type="button" name="button" class="button" value="Search" onclick="javascript:get(this.parentNode);" />-->	  </td>
  </tr>
    </table>
</form>
    </div>
  </div>
    <div class="searchBase"></div>
    <div class="clear"></div>
  </div>
  <div id="result">

  <div class="thumbnailsDisplayArea">

   <?php if(!isset($_GET['page']) || ($_GET['page']==1)) { $i=1; }
	  	else { $i=(($_GET['page']-1)*10)+1 ; }

		if(mysql_num_rows($rs)>0)
		  			  {
		   					while($row_fetch=mysql_fetch_assoc($rs))
							{?>
							  <?PHP $i++; ?>


      <div class="listPanel">
        <div class="listTop"></div>
        <div class="listMid">
          <a href="boat_detail.php?id=<?php echo $row_fetch ['boat_id'];?> & common_id=<?php echo $row_fetch['common_id']; ?>"><div class="itemName" align="left"><?php echo $row_fetch['boat_title'];?> </div></a>
         <div class="itemPrice"><?php echo $row_fetch['price_currency'];?> <?php echo $row_fetch['boat_price'];?></div>
         <div class="clear"></div>
        <div class="itemDescription" align="left">
            <a href="boat_detail.php?id=<?php echo $row_fetch['boat_id'];?>&common_id=<?php echo $row_fetch['common_id']; ?>"><?php echo $row_fetch['boat_summary'];?></a>
		 <div class="moreLink"><!--<a href="boat_detail.php?id=<?php //echo $value['boat_id'];?> & common_id=<?php //echo $com_id?>">more...</a>--></div>
             <div class="clear"></div>
        </div>

         <div class="ItemThumbnail">
	 <a href="boat_detail.php?id=<?php echo $row_fetch ['boat_id'];?>&common_id=<?php echo $row_fetch['common_id'];?>">

	  <?php
	  ///////exit;
		$where=sprintf("common_id=%d",$row_fetch['common_id']);
	  	$obj ->select('boat_images','',$where);
		$array = $obj ->get('');
		if(count($array)>0){

		$imagename=$array[0]["boat_image"];

	  $thumb_name="thumb/thumb_$imagename";
	  $thumb_name=str_replace("jpg","png",$thumb_name);


	   if(!file_exists($thumb_name))
	  {

		   $thumb -> Createthumb("admin/uploads/$imagename","file");
	  }
	?><?php
	}
	?>
	<img src="<?php echo $thumb_name; ?>" border=0 />
	</a><br />
   </div>
        </div>

        <div class="listBase"></div>
      </div>

      <div class="clear"></div>


<?php }}else {
	echo 'NO image found';}?>
<div class="paging2">
  <?php
  		if(mysql_num_rows($rs)>0){
   echo $pager->renderFullNav(); }?>
    <div class="clear"></div>
  </div></div>

<div class="verticalSpacer"></div>


  <div class="clear"></div>
  <div class="line"></div>
  <div class="footer">
  <?php  include($footer);?></div>
   <?php include('language.php');?>
<div class="clear"></div>
</div>
</div>



</body>
</html>

 

Kindregarts

Link to comment
https://forums.phpfreaks.com/topic/221009-page-row/
Share on other sites

Do i need to change somthing in here:

to change all the pages, too one page?

 

 

<div class="thumbnailsDisplayArea">   <?php if(!isset($_GET['page']) || ($_GET['page']==1)) { $i=1; }		  	else { $i=(($_GET['page']-1)*10)+1 ; }			if(mysql_num_rows($rs)>0)			  			  {			   					while($row_fetch=mysql_fetch_assoc($rs))								{?>								  <?PHP $i++; ?>

 

Kindregarts

Link to comment
https://forums.phpfreaks.com/topic/221009-page-row/#findComment-1144373
Share on other sites

I found this code///

 

 

<?php
/**
* PHPSense Pagination Class
*
* PHP tutorials and scripts
*
* @package		PHPSense
* @author		Jatinder Singh Thind
* @copyright	Copyright (c) 2006, Jatinder Singh Thind
* @link		http://www.phpsense.com
*/

// ------------------------------------------------------------------------

class PS_Pagination {
var $php_self;
var $rows_per_page; //Number of records to display per page
var $total_rows; //Total number of rows returned by the query
var $links_per_page; //Number of links to display per page
var $sql;
var $debug = false;
var $conn;
var $page;
var $max_pages;
var $offset;

/**
 * Constructor
 *
 * @param resource $connection Mysql connection link
 * @param string $sql SQL query to paginate. Example : SELECT * FROM users
 * @param integer $rows_per_page Number of records to display per page. Defaults to 10
 * @param integer $links_per_page Number of links to display per page. Defaults to 5
 */

function PS_Pagination($connection, $sql, $rows_per_page = 30, $links_per_page = 10) {
	$this->conn = $connection;
	$this->sql = $sql;
	$this->rows_per_page = $rows_per_page;
	$this->links_per_page = $links_per_page;
	$this->php_self = htmlspecialchars($_SERVER['PHP_SELF']);
	if(isset($_GET['page'])) {
		$this->page = intval($_GET['page']);
	}
}

/**
 * Executes the SQL query and initializes internal variables
 *
 * @access public
 * @return resource
 */
function paginate() {
	if(!$this->conn) {
		if($this->debug) echo "MySQL connection missing<br />";
		return false;
	}

	$all_rs = @mysql_query($this->sql);
	if(!$all_rs) {
		if($this->debug) echo "SQL query failed. Check your query.<br />";
		return false;
	}
	$this->total_rows = mysql_num_rows($all_rs);
	@mysql_close($all_rs);

	$this->max_pages = ceil($this->total_rows/$this->rows_per_page);
	//Check the page value just in case someone is trying to input an aribitrary value
	if($this->page > $this->max_pages || $this->page <= 0) {
		$this->page = 1;
	}

	//Calculate Offset
	$this->offset = $this->rows_per_page * ($this->page-1);

	//Fetch the required result set
	$rs = @mysql_query($this->sql." LIMIT {$this->offset}, {$this->rows_per_page}");
	if(!$rs) {
		if($this->debug) echo "Pagination query failed. Check your query.<br />";
		return false;
	}
	return $rs;
}

/**
 * Display the link to the first page
 *
 * @access public
 * @param string $tag Text string to be displayed as the link. Defaults to 'First'
 * @return string
 */
function renderFirst($tag='First') {
	if($this->page == 1) {
		return $tag;
	}
	else {
		return '<a href="'.$this->php_self.'?page=1">'.$tag.'</a>';
	}
}

/**
 * Display the link to the last page
 *
 * @access public
 * @param string $tag Text string to be displayed as the link. Defaults to 'Last'
 * @return string
 */
function renderLast($tag='Last') {
	if($this->page == $this->max_pages) {
		return $tag;
	}
	else {
		return '<a href="'.$this->php_self.'?page='.$this->max_pages.'">'.$tag.'</a>';
	}
}

/**
 * Display the next link
 *
 * @access public
 * @param string $tag Text string to be displayed as the link. Defaults to '>>'
 * @return string
 */
function renderNext($tag=' >>') {
	if($this->page < $this->max_pages) {
		return '<a href="'.$this->php_self.'?page='.($this->page+1).'">'.$tag.'</a>';
	}
	else {
		return $tag;
	}
}

/**
 * Display the previous link
 *
 * @access public
 * @param string $tag Text string to be displayed as the link. Defaults to '<<'
 * @return string
 */
function renderPrev($tag='<<') {
	if($this->page > 1) {
		return '<a href="'.$this->php_self.'?page='.($this->page-1).'">'.$tag.'</a>';
	}
	else {
		return $tag;
	}
}

/**
 * Display the page links
 *
 * @access public
 * @return string
 */
function renderNav() {
	for($i=1;$i<=$this->max_pages;$i+=$this->links_per_page) {
		if($this->page >= $i) {
			$start = $i;
		}
	}

	if($this->max_pages > $this->links_per_page) {
		$end = $start+$this->links_per_page;
		if($end > $this->max_pages) $end = $this->max_pages+1;
	}
	else {
		$end = $this->max_pages;
	}

	$links = '';

	for( $i=$start ; $i<$end ; $i++) {
		if($i == $this->page) {
			$links .= " $i ";
		}
		else {
			$links .= ' <a href="'.$this->php_self.'?page='.$i.'">'.$i.'</a> ';
		}
	}

	return $links;
}

/**
 * Display full pagination navigation
 *
 * @access public
 * @return string
 */
function renderFullNav() {
	return $this->renderFirst().' '.$this->renderPrev().' '.$this->renderNav().' '.$this->renderNext().' '.$this->renderLast();
}

/**
 * Set debug mode
 *
 * @access public
 * @param bool $debug Set to TRUE to enable debug messages
 * @return void
 */
function setDebug($debug) {
	$this->debug = $debug;
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/221009-page-row/#findComment-1144404
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.