English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am using the code below to display the content of my table named (data)


Your Page Title

$database="ac_au";
mysql_connect ("localhost", "aci_au", "abcd");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT * FROM data" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.

";
print "

\n";
while ($get_info = mysql_fetch_row($result)){
print "\n";
foreach ($get_info as $field)
print "\t\n";
print "\n";
}
print "
$field
\n";
?>



I am not to good at php, but can anyone provide me with help regarding the same?
the code works fine, it displays what i want.. but now i wanted to display only 10 rows on one page and my table contains (400 rows)
i want to have a navigation option !

2007-11-08 20:37:44 · 4 answers · asked by legna 2 in Computers & Internet Programming & Design

can anyone realy provide me a solution? to the code i am using, what and where should i add? if the code can be modified and given i would really be thankful... the codes in every article confuse me as am not into php. if sum1 modifies the code am using to work with pagination. i can study it :) thanx a lot

2007-11-09 15:19:38 · update #1

4 answers

Pagination is definitely the way to go. See the 3 articles in my sources list.

2007-11-09 13:19:16 · answer #1 · answered by Adam 3 · 0 0

Use mysql_num_rows to get the number of rows.
Calculate the limits of the rows you want (say you want rows 10 to 30)
$offset = 10; // start from row 10
$rowcount = 20; // (30 -10!) = number of rows.
Place your query:
$list = mysql_query( "SELECT * FROM data LIMIT " . $offset . " , " . $rowcount . " )
// $list will return rows 10 to 30
while ($lst = mysql_fetch_array ($lst))
{
do something
}

2007-11-08 21:39:15 · answer #2 · answered by just "JR" 7 · 0 0

you can login for free at www.dreamincode.net , read the forum rules, then post your programming questions there. There are a lot great hardcore programmers there around the world.

My screenname is 'nirvanarupali' and usually haning out at C/C++ forum.

2007-11-12 20:33:43 · answer #3 · answered by nirvana r 2 · 0 0

You want to look into pagination.

There are quite a look of tutorials, take a look here
http://www.google.com/search?hl=en&q=php+pagination

2007-11-08 20:43:41 · answer #4 · answered by Maller 4 · 0 0

fedest.com, questions and answers