| | |
display fix set of data in table....
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 6
Reputation:
Solved Threads: 0
Hi guys...Good morning...I have following code.
<?php
$pid=$_GET['pid'];
$conn=mysql_connect('localhost','root','') or die("Cannot connect to server");
mysql_select_db('developer',$conn) or die("Cannot connect to database");
$sql="select cnode,item,pnode from listviews where cnode='$pid'";
$res=mysql_query($sql) or die("Cannot execute query");
while($ar=mysql_fetch_array($res))
{
$itm=$ar[1];
$pid=$ar[0];
}
$sql="select cnode,item,pnode from listviews where pnode='$pid'";
$res=mysql_query($sql) or die("Cannot execute query");
echo "<table border='1'>";
if($pid==0)
echo "<th colspan=2>Parent Items</th>";
else
echo "<th colspan=2>$itm</th>";
while($ar=mysql_fetch_array($res))
{
echo "<tr><td>$ar[0]</td><td>$ar[1]</td>";
}
echo "</table>";
?>
Now i want to display only five rows per page...and using next button i want to see next five records...How it is possible to display it using PHP...This page is called by ajax script...Please show me the way...Thank you...
<?php
$pid=$_GET['pid'];
$conn=mysql_connect('localhost','root','') or die("Cannot connect to server");
mysql_select_db('developer',$conn) or die("Cannot connect to database");
$sql="select cnode,item,pnode from listviews where cnode='$pid'";
$res=mysql_query($sql) or die("Cannot execute query");
while($ar=mysql_fetch_array($res))
{
$itm=$ar[1];
$pid=$ar[0];
}
$sql="select cnode,item,pnode from listviews where pnode='$pid'";
$res=mysql_query($sql) or die("Cannot execute query");
echo "<table border='1'>";
if($pid==0)
echo "<th colspan=2>Parent Items</th>";
else
echo "<th colspan=2>$itm</th>";
while($ar=mysql_fetch_array($res))
{
echo "<tr><td>$ar[0]</td><td>$ar[1]</td>";
}
echo "</table>";
?>
Now i want to display only five rows per page...and using next button i want to see next five records...How it is possible to display it using PHP...This page is called by ajax script...Please show me the way...Thank you...
Simplest 'next-forward' script, just to get the idea on how it works. You will find much more efficient code on the net.
Cheers,
Nav
php Syntax (Toggle Plain Text)
<?php $offset=isset($_REQUEST['offset'])?$_REQUEST['offset']:0; $conn=mysql_connect("localhost","root"); mysql_select_db("test"); $total=mysql_num_rows(mysql_query("select * from test")); $query="select * from test limit $offset,5"; $result=mysql_query($query); while($row=mysql_fetch_array($result,MYSQL_ASSOC)){ print_r($row); } if($offset==0){ $next_offset=$offset+1; $prev_offset=0; } elseif($offset == $total) { $next_offset=$total; $prev_offset=$offset-1; } else { $next_offset=$offset+1; if($next_offset==$total){ $next_offset=$total; } $prev_offset=$offset-1; } echo "<a href=test.php?offset=$prev_offset>Prev</a>"; echo "<a href=test.php?offset=$next_offset>Next</a>"; ?>
Cheers,
Nav
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- wallpaper locked after removing pest trap (Viruses, Spyware and other Nasties)
- pass the value to the text box (JavaScript / DHTML / AJAX)
- Open In New Window Php (PHP)
- javascript works in IE but not working in firefox (JavaScript / DHTML / AJAX)
- I NEED HELP PLEASE:Warning: mysql_num_rows(): (PHP)
- I NEED HELP PLEASE:Warning: mysql_num_rows(): (MySQL)
- Warning: mysql_num_rows(): (PHP)
- help with reading these logs (Viruses, Spyware and other Nasties)
- This ought to be simple - extra spaces (PHP)
Other Threads in the PHP Forum
- Previous Thread: I am new to this whole thing...
- Next Thread: Linking mysql output results
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu method mlm mod_rewrite multiple mysql oop pageing pagerank parse paypal pdf php printer problem query radio random recursion recursiveloop regex remote script search server sessions sms soap source space sql structure subversion support! syntax system table template tutorial update upload url validation validator variable video web xml youtube






