If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > DB question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-07, 13:47
matik matik is offline
Registered User
 
Join Date: Feb 2007
Posts: 2
Arrow DB question, please help!

Hi!

I have a table.. Structure is:
PHP Code:
-- 
-- 
Table structure for table `database`
-- 

CREATE TABLE `database` (
  `
IDvarchar(255) default NULL,
  `
Quotevarchar(255) default NULL,
  `
Namevarchar(255) default NULL,
  
KEY `Name` (`Name`)
ENGINE=MyISAM DEFAULT CHARSET=latin1
And for example few entries..
PHP Code:
INSERT INTO `databaseVALUES ('12714''"Do what thou wilt" shall be the whole of the law.''Aleister Crowley'); 
I'm using this code, to call my database values into my site.
PHP Code:
$result mysql_query("SELECT * FROM database ORDER BY ID"
or die(
mysql_error());  

echo 
"<table border='0'>";
echo 
"<tr> <th>ID</th> <th>Quote</th> <th>Author</th> </tr>";

while(
$row mysql_fetch_array$result )) {

    echo 
"<tr><td>"
    echo 
$row['ID'];
    echo 
"</td><td>"
    echo 
"<cite>".$row['Quote']."</cite>";
    echo 
"</td><td>"
    echo 
$row['Name'];
    echo 
"</td></tr>"

It throws me all entries in one page.. Can i have for example 10 entries in one page, and 10 in the other & so on...

thanks in advance

Last edited by matik; 02-27-07 at 13:58.
Reply With Quote
  #2 (permalink)  
Old 02-27-07, 16:28
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,259
as you are using PHPyou could use a prewritten class..... have a look at phpclasses I think there is a paging class there

if that isnt suitable then you need to roll your own function that calls the page recursively with a page or record number and the same search parameters

you then extract the records you want using the limit function
say if you displayed 20 records per page, and you want to display page 5 then you need the first 100 records, you bin records 1..80, and display 81..100

HTH
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On