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> ";
}
}
$_FILES array
Ok,I just started experimenting with PHP today. My goal right now is to have people be able to upload files to my website, but I am starting at square one. I can make a .php print out the name of
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
Why is the logic of this simple code not working?
Hey, I'm trying to determine if a table already exists in mysql, but doing a query first with mysql_query, then checking $sql as if it a were TRUE of FALSE. Which I though it would be. My Code
Links not updating
I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to retrieving and displaying data, but if I click on a valid link in the following code, the content and
links using header()
Hi AllI'm not sure where to ask for help on this but I hope someone can offer some. I'm at the point now where I'm trying to make my website live and the problem I've come across is updating my
$_POST variable un-useable
I'm trying to use a $_POST variable in a mysql update statement but i can't use it for some unknown reason i can echo the variable and it outputs the correct value but i cannot use that variable in
Need help Updating SQL Server Express DB from c# :(
Please can anyone help with:-
Am i doing this wrong?
Im pulling from an Oracle database some info... one of which is a field count_pnums which is a NUMBER type field.Code: <?php$sql_E = "SELECT count_pnums, dist_pnums FROM
Socket Server
In my following socket server, I am trying to listen to a connection through port 12345 in my web browser. http://127.0.0.1:12345/I assumed that the following would detect that something was trying to
PHP If Else statement for breadcrumb
HiI am trying to use a PHP if else statement to display a breadcrumb link on wordpressThe codeLine number On/Off | Expand/Contract <div class="triple silhouette_break">