944,161 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5174
  • PHP RSS
Jun 30th, 2006
0

pagination of mysql query results

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ShazB2K is offline Offline
2 posts
since Jun 2006
Jul 5th, 2006
0

Re: pagination of mysql query results

see http://www.php-mysql-tutorial.com/php-mysql-paging.php
so far the best tutorial I've seen about paging your results
Reputation Points: 10
Solved Threads: 7
Posting Whiz in Training
zippee is offline Offline
294 posts
since Jan 2005
Jul 6th, 2006
0

Re: pagination of mysql query results

Please wrap code in [ code ] and [/ code ] tags.
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: trouble setting up PHP with apache
Next Thread in PHP Forum Timeline: list box --php issue





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC