dannybarh's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 27 (0.03 per day)
- Joined:
- 19-February 11
- Profile Views:
- 1,516
- Last Active:
Nov 16 2012 12:54 AM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Undefined variable in pagination script
Posted 18 Oct 2012
sorry for all the troubles , i just solved it.$myid
had no value, hence the error. It shld have contained the value of$userId
thanks a million for your time. -
In Topic: Undefined variable in pagination script
Posted 17 Oct 2012
Dormilich, on 17 October 2012 - 02:45 PM, said:
well, this is the pagination class.am sorry its very long.
<?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 = 15, $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 { $navtype = $_GET['nav']; return '<a href="'.$this->php_self.'?page=1&nav='.$navtype.'">'.$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 { $navtype = $_GET['nav']; return '<a href="'.$this->php_self.'?nav='.$navtype.'&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='<img src=images/forward.gif border=0>') { if($this->page < $this->max_pages) { $navtype = $_GET['nav']; return '<a href="'.$this->php_self.'?nav='.$navtype.'&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='<img src=images/backward.gif border=0>') { if($this->page > 1) { $navtype = $_GET['nav']; return '<a href="'.$this->php_self.'?nav='.$navtype.'&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 { $navtype = $_GET['nav']; $links .= ' <a href="'.$this->php_self.'?nav='.$navtype.'&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; } } ?> -
In Topic: Undefined variable in pagination script
Posted 17 Oct 2012
Dormilich, on 17 October 2012 - 01:51 PM, said:
dannybarh, on 17 October 2012 - 03:02 PM, said:but when i do this
$query = "select * FROM aboutusx WHERE myaccountid='$myid' order by title desc";
then i get this
Notice: Undefined variable: start in D:\xampp\htdocs\kwa\admin\userindex\inc\ps_pagination.php on line 176
those two are unrelated. the message is about a variable $start (probably in a context along $start .= "some string"; without prior initialisation), which is nowhere in the given code. are you sure you’re looking in the right file? from line #3 I would deduce, that ps_pagination.php is a class definition file.
Yes its ps_pagination.php is a class definition.
Is there a way i can do this without using the class definition? -
In Topic: Displaying Data From Multiple MySQL Tables
Posted 27 Aug 2012
db_table.png (27.38K)
Number of downloads: 16
rnty, on 25 August 2012 - 01:55 AM, said:Have you tried it using Joins?Please give more information about the tables'(tuples and attributes) and the columns you want to select.
Here is a picture of my db,am trying to select from the illness table where its ID corresponds with that of the symptoms ID -
In Topic: Displaying Data From Multiple MySQL Tables
Posted 27 Aug 2012
rnty, on 25 August 2012 - 01:55 AM, said:Have you tried it using Joins?Please give more information about the tables'(tuples and attributes) and the columns you want to select.
Here is a picture of my db,am trying to select from the illness table where its ID corresponds with that of the symptoms ID
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
dannybarh has no profile comments yet. Why not say hello?