Hi, i have been trying for days but couldn't get this sorted out. Would like some professional help here.
Basically I got a basic pagination script from google search and the script works absolutely well if i am to display the full results.
However i am using the 'SELECT...WHERE.. LIKE %$val%' and the result works well for the 1st page but not on the 2nd or 3rd page. i had a search form to submit my value. Some help as to where i should proceed is greatly appreciated! Cheers
Here's my coding:
form.php
Code: <form action="FTsearch.php" method="post">
<table border=0 cellspace=1 cellpadding=3 bgcolor;"#353535"
align="center">
<tr>
<td bgcolor="#eeeeff" width="50%">
Device Number
</td>
<td bgcolor="#eeeeff" width="50%">
<INPUT type = "TEXT" name = "devicesearch">
</td>
</tr>
<tr>
<td bgcolor ="eeeeff" colspan=2 align="center">
<INPUT Type="SUBMIT" name="submit" value="Device Search">
</td>
</tr>
</table>
</form>
FTsearch.php
Code: $val_d = $_POST['devicesearch'];
if ($_POST['SEARCH'] = 'Device Search')
{
$sql = "SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d'";
$results1 = mysql_query($sql) or die ("Sorry no match found!".mysql_error());
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
$pagenum = $_GET['pagenum'];
echo "<center>";
/* if(!isset($_GET['page'])) {
$pagenum = 1;
} else {
$pagenum = $_GET['page'];
} */
$numrows = mysql_num_rows($results1);
$page_rows = 10; //This is the number of results displayed per page
$last = ceil($numrows/$page_rows); //This tells us the page number of our last page
if ($pagenum < 1) //this makes sure the page number isn't below one, or more than our maximum pages
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This sets the range to display in our query
$sql = "SELECT *
FROM device
WHERE device_num LIKE '%$val_d%' or '%$val_d' $max";
$results = mysql_query($sql) or die (mysql_error());
// this is the result display
include "FTsearchtable.php";
echo "
<center>Page $pagenum of $last
"; // This shows the user what page they are on, and the total number of pages
// First we check if we are on page one.
//If we are then we don't need a link to the previous page or the first page so we do nothing.
//If we aren't then we generate links to the first page, and to the previous page.
if($pagenum>1)
{
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=1'>First</a> ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$previous'>Previous</a> ";
}
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else
{
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$next'>Next</a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$last'>Last</a> ";
}
}
Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postback is occuring in my page. Can you please suggest something that prevents my page from being
Print out contents of to Excel
I have got this script that gathers all the data that I need but I need it to send it to excel instead back to the screen in the web browser. How can I do this? Should I use something
array ...
hiCode: function formatCategories($categories, $parentId){ // $navCat stores all children categories // of $parentId $navCat = array(); // expand only the categories with the same parent id
RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mail is sent correctly, but the formatting of the content includes rtf formatting like:
PHP Captcha Error help - replace the "die" command
Hi All,I am after a bit of help with a Captcha spam protection box.The site gave me instructions, and all is well, apart from if the user give the wrong Captcha information...The highlighted code is
2 decima places & How to reload my page
Hello There,How do i put full-stop (.) after second figure from behind? ie if i have 123456 in my database and i want it to echo as 1234.56Secondly, am designing a shopping website. I want the pages
Guixt issue
Hello all,
button help
i originally had this but realised it is much easier to have a button.Code: <?php$search = $_GET['search'];$checkbox = $_GET['checkbox'];if($checkbox ==
php forms and database navigatio
Hello,I'm new to php and i'd like to post the following.I have written code to get records from a DB and i need one record at a time to be filled in a form i created. Then the next record should be
Validating time
Hi Guyswhat do you think of the following approach to validate a 24hour time:http://snipplr.com/view/23007/validate-time/Are there any better approaches ?