User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,548 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,549 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2370 | Replies: 2
Reply
Join Date: Jun 2006
Posts: 2
Reputation: ShazB2K is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ShazB2K ShazB2K is offline Offline
Newbie Poster

pagination of mysql query results

  #1  
Jun 30th, 2006
Hi,

Um new to php... kindly help me on the following...


<?php
$action = $_SERVER['SCRIPT_NAME'];
?>
<?php
//if(!$_POST['search']=='result')
//{echo "<p style=' font-family: arial; color: blue; font-size: 14px;'>You are not authorized!</p>"; return false;}
//$choice=$_POST['choice'];
$name=$_POST['name'];

$link=mysql_connect("localhost", "root", "") or die("<p class='texxt'>Can't connect to server: ".mysql_error());
mysql_select_db("test",$link);
$query="SELECT * FROM saudi_journal WHERE match (FAU, TI, AU, SO, PT, DP, MESH, KW, TA, AD, ISSN, NOTE) against ('$name' in boolean mode) ORDER BY DP DESC";
$result=mysql_query($query,$link) or die("Cannot find Server: ".mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows=="0"){$search_result="<p class='error'>No Results Found</p>";}
elseif ($num_rows > 0){$search_result="<p class='error'>".$num_rows. " Articles Found</p>";}

?>
<body topMargin="0" onLoad="dynAnimation()" vlink="#0000FF" alink="#0000FF" bgcolor="#fffff0" language="Javascript1.2">
<div align="left">
<table border="0" cellPadding="0" cellSpacing="0"
height="112" width="100%">
<tbody>
<tr>
<td height="112" width="994"><img border="0" src="img/x.gif" width="990" height="102"></td>
</tr></tbody></table></div>
<div align="left">
<table border="0" cellPadding="0" cellSpacing="0" width="100%">
<tbody>
<tr>
<td valign="top">
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" width="979">
<tr>
<td width="312">
</td>
<td align="center" width="355">
<a onMouseOver="document['fpAnimswapimgFP2'].imgRolln=document['fpAnimswapimgFP2'].src;document['fpAnimswapimgFP2'].src=document['fpAnimswapimgFP2'].lowsrc;" onMouseOut="document['fpAnimswapimgFP2'].src=document['fpAnimswapimgFP2'].imgRolln" href="javascript:void(0)">
<img border="0" src="img/hsl1.gif" id="fpAnimswapimgFP2" name="fpAnimswapimgFP2" dynamicanimation="fpAnimswapimgFP2" lowsrc="img/HSL2.gif" width="354" height="25"></a></td>
<!-- Search Google -->
<form method=GET action=http://www.google.com/custom>
<td width="312" align="right">&nbsp;&nbsp;
<input type=hidden name=cof VALUE="AH:center;LH:36;L:http://www.nwafh.med.sa/eng/HTML/libweb/img/HSL-NWAFH.gif;LW:432;AWFID:8099ac48bde120fe;">
</td></form>
</tr>
</table>
</div>
</td></tr></tbody></table></div>
<div align="left">
<table background="img/bg2.gif" border="0" cellPadding="0" cellSpacing="0"
width="989">
<tbody>
<tr>
<td width="845">
<p align="left"><a href="Index.htm"><img border="0" src="img/Home.gif" width="161" height="31"></a><img border="0" src="img/SPACE.gif" width="10" height="10"><a href="about.htm"><img border="0"
src="img/ABOUT.gif" width="116" height="31"></a><img border="0"
src="img/SPACE.gif" width="10" height="10"><a href="services.htm"><img border="0"
src="img/SERVICES.gif" width="116" height="31"></a><img border="0"
src="img/SPACE.gif" width="10" height="10"><a href="ejournals.htm" target="_self"><img border="0" src="img/JOURNAL.gif" width="116" height="31"></a><img border="0"
src="img/SPACE.gif" width="10" height="10"><a href="eb.htm"><img border="0"
src="img/BOOKS.gif" width="116" height="31"></a><img border="0"
src="img/SPACE.gif" width="10" height="10"><a href="databases.htm"><img border="0"
src="img/DATABASE.gif" width="116" height="31"></a></p></td>
<td width="140">
<p align=center>&nbsp;</p></td></tr></tbody></table></div>
<div align=center>
<center>
<table border="0" cellPadding="2" cellSpacing="3" width="108%">
<tbody>
<tr>
<td width="145" rowspan="2" valign="top" bgcolor="#339966">
<p align="center"><b><font size="4">NWAFH<br>
</font><font size="2">Health Sciences Library </font></b></p>
<table id="table2" width="103%" border="0">
<tr>
<td align="left"><font color="#ffffff" size="2">About
SaudiMedLit</font></td>
</tr>
<tr>
<td align="left"><font color="#ffffff" size="2">Journal List</font></td>
</tr>
<tr>
<td>
<p align="left"><font color="#ffffff" size="2">Issues Indexed To
Date</font></td>
</tr>
<tr>
<td><font size="2">&nbsp;</font></td>
</tr>
<tr>
<td>
<p align="left" class="style20"><a href="tips1.htm" class="style21">Search Tips</a></td>
</tr>
</table>
<p></td>
<td width="900">

<form name="search_form" action="display3.php" method="post">
<div align="center">
<input type="hidden" name="search" value="result" />
<b>&nbsp;<font size="4" color="#0000ff"><br>
</font><span class="style22"><font color="#0000ff">SaudiMedLit</font></span></b>
<font size="2">
<font color="#008000">is a service of the Health Sciences
Library, North West Armed Forces Hospital, Tabuk, KSA</font>&nbsp;</font>
</div>
<p align="center">
<b>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; SEARCH&nbsp;&nbsp;&nbsp;&nbsp; </b>
<SELECT name="choice" size="1">
<!-- <option value="books">Books</option> -->
<option value="smj">Saudi Medical Journals</option>
<!-- <option value="staffpub">Staff Publications</option> -->

</SELECT>
<b>FOR</b>
<input name="name" />
<input name="B1" type="button" value="Go!" onClick="search_submit()" />&nbsp;&nbsp;&nbsp;&nbsp;
</p>
</form>


</td>
<td width="1">&nbsp;</td>
</tr>
<tr>
<td colspan="2" width="870">
<?php


echo '<table border="0" cellspacing="10">';
echo '<tr>';
echo '<td colspan="2" class="staffpub_title" align= "center"><font color="blue" size="4"> Search Results </font></td>';
echo '</tr>';
echo '<tr><td align="center" colspan="2"><font color="red" face="Georgia, Times New Roman, Times, serif">'.$search_result.'</font></td></tr>';
while ($rs = mysql_fetch_array($result)){
$TI=$rs['TI'];
$AU=$rs['AU'];
$FAU=$rs['FAU'];
$SO=$rs['SO'];
$DP=$rs['DP'];
$PT=$rs['PT'];
$MESH=$rs['MESH'];
$KW=$rs['KW'];
$TA=$rs['TA'];
$TF=$rs['TF'];
$EDTA=$rs['EDAT'];
$AD=$rs['AD'];
$ISSN=$rs['ISSN'];
$NOTE=$rs['NOTE'];
$EB=$rs['EB'];

echo '<tr>';
echo '<td width="200" align="right" valign="top"><b>Title of the Article: </b></td>';
echo '<td align="left" valign="top">'.$TI.'</td>';
echo '</tr>';
echo '<tr>';
echo '<td align="right" valign="top"><b>Author(s) : </b></td>';
echo '<td align="left" valign="top">'.$AU.'</td>';
echo '</tr>';

echo '<tr>';
echo '<td align="right" valign="top"><b>Source :</b></td>';
echo '<td align="left" valign="top">'.$SO.'</td>';
echo '</tr>';

echo '<tr>';
echo '<td align="right" valign="top"><b>Address of the Author: </b></td>';
echo '<td align="left" valign="top">'.$AD.'<hr></td>';


echo '</tr>';

echo '<tr>';
echo '<td colspan="2" class="staffpub_left">&nbsp;</td>';
echo '</tr>';}

echo '</table>';

?>
<p>&nbsp;</p>
<p><br />
</p>
<p></td>
</tr></tbody></table>
</center></div>
<div align=left>
<table bgColor=#000000 border="0" cellPadding="2" cellSpacing="3" width="1010" height="41">
<tbody>


I have made the above basic script to query the mysql database and display the result. right now all the results are displayed in one page. I want the results to be displayed in several pages if my search result is more than 10 . Can any one please help me to modify this script.

thank you in advance.

Rgd,
Shaz
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: pagination of mysql query results

  #2  
Jul 5th, 2006
see http://www.php-mysql-tutorial.com/php-mysql-paging.php
so far the best tutorial I've seen about paging your results
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation: Puckdropper is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 20
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: pagination of mysql query results

  #3  
Jul 6th, 2006
Please wrap code in [ code ] and [/ code ] tags.
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC