PHP - Php Search Page Help Please!!
I have code for a perv. and next links at the bottom of my search page. Which shows the next ten results however when the next link is clicked the page says please fill in all fields (as if the search box was left empty and the search button was clicked... please help me figure this out...
Code: [Select] <?php // Get the search variable from URL $var = $_GET['search']; $searchtype = $_GET['searchtype']; $isbn = "ISBN"; $school = "School"; $title = "Title"; $subject = "Subject"; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database $connect = mysql_connect("db","user","pass") or die("Not connected"); //specify database mysql_select_db("user") or die("could not log in"); if ($searchtype == ($title)) { // Build SQL Query $query = "select * from boox where name like \"%$trimmed%\" order by name"; // EDIT HERE and specify your table and field names for the SQL query } elseif ($searchtype == ($school)) { // Build SQL Query $query = "select * from boox where school like \"%$trimmed%\" order by school"; // EDIT HERE and specify your table and field names for the SQL query } elseif ($searchtype == ($isbn)) { // Build SQL Query $query = "select * from boox where isbn like \"%$trimmed%\" order by isbn"; // EDIT HERE and specify your table and field names for the SQL query } elseif ($searchtype == ($subject)) { // Build SQL Query $query = "select * from boox where subject like \"%$trimmed%\" order by subject"; // EDIT HERE and specify your table and field names for the SQL query } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . "" in "" . $searchtype ."" </p>"; // begin to show results set echo "Results "; $count = 1 + $s ; if ($searchtype = $title) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["name"]; echo "$count. $title   </br><table width='297' border='1' align='center'> <tr> <td width='152'>Book Title:</td> <td width='129'>$row[name]</td> </tr> <tr> <td>Author:</td> <td>$row[author]</td> </tr> <tr> <td>ISBN#</td> <td>$row[isbn]</td> </tr> <tr> <td>Date Posted:</td> <td>$row[date]</td> </tr> <tr> <td>Posted By:</td> <td><a href='backpack.php?usr=$row[username]'>$row[username]</a></td> </tr> <tr> <td>School:</td> <td>$row[school]</td> </tr> </table></br>"; $count++ ; } } elseif ($searchtype = $school) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["school"]; echo "$count. $title" ; $count++ ; } } elseif ($searchtype = $subject) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["subject"]; echo "$count. $title" ; $count++ ; } } elseif ($searchtype = $isbn) { // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["isbn"]; echo "$count. $title" ; $count++ ; } } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&search?q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> Similar TutorialsThe result pages is supposed to have pagination like google help me please
hello, was wondering if there is a way to have a search box that searches all data on the current page. similar to what a ctrl+F would do in internet exoplorer i have a html page which is derived from an excel spreedsheet. is it possable to use php to search the page and pull a row of data from it and store them as $vars ? sort of treat it as a database. if so can you point me in the right direction. i tryed google with no luck. cheers How can I write a 404 file to redirected any 'not found' page with structure of example.com/something/more/final.html to example.com/search?q=something+more+final Thanks Hi all. I am in need of some help with a simple page search function. In short what i need is a way the user can search for a specific page name from the home index page. My site (local for now) will be constructed as follows: localhost/mysite/index.html 0001.html 0002.html ... 0132.html etc... The subpages will be added/modified externaly and may run into the hundreds of pages. For this reason mySQL will be hard to implement and somewhat overkill especialy for this simple search function. So, is there a way i can type the page to look for "0132" into the field and be forwarded onto the searched page "0132.html" I realise i could just type mysite/0132.html but the page may or may not exist and searching would be tiny bit more elegant. Simple for you guys i expect but im at a loss as all search functions use mySQL in addition. Many thanks for your help in advance! Regards, Matt.
hello everyone. i'm having problem to create a search page. i want to create a search page like this but i dont have the coding source to refer.. can anyone give me the coding for me to refer.... Help Please Hi, I have a website which displays products on product display pages and static pages such as 'contact us'. I am now looking to add a search function which directs to the display page so the products are neatly presented. However, all the tutorials I can find are based on displaying the echo on same page as the search and directing the search to another page. Does anyone know how to do this? The php web video script that I'm using displays user/member account pages in google searches. For example, the url displaying the page is the https://webvideosite.com/@chrisj I'm looking for guidance/suggestions on how to have the user/member account pages not appear in searches, either by blocking that somehow, or only having access to it if you are logged into the site. I look forward to any replies http://2eastvalleyhomes.expandyourwebpresence.com/ In this site on the right widget the search option opens a new page and directs you off the page. I have created a page not visible on the home page called MLS and I would like the search on the right side to have its information populate in a page I created in my wordpress site, does any one have any suggestions or any ideas for this thank you for any help. Sorry if this should be in the HTML forum but as it is relating to something I am trying to do with php I thought this was the right place! I am creating a search page and one of the columns has only two potential values, 'H' for Home Games and 'A' for Away Games. Using radio buttons I can get the search page to filter correctly but there will also be times, once there are a few more search options on there, when a search would want to show All Games. The current form I have is Code: [Select] <form id="form1" name="form1" method="post" action="fixrestestsearch.php"> <p> <label for="OPP">OPP</label> <input type="text" name="OPP" id="OPP" /> <br /> <label> <input type="radio" name="HA" value="H" id="HA_0" /> Home</label> <br /> <label> <input type="radio" name="HA" value="A" id="HA_1" /> Away</label> <br /> <label> <input type="radio" name="HA" value="" id="HA_2" /> All</label> <br /> <br /> SUB <input type="submit" name="SUB" id="SUB" value="Submit" /> </p> </form> and the query in the results page contains Code: [Select] WHERE team_name='$OPP' AND h_a='$HA' If either the 'Home' or 'Away' buttons are checked everything works fine. If I check the 'All' button nothing is returned as it is looking for blank cells. I have also tried using 'value="*"' but that did not work. Is there anything that I can put as the value of a radio button that would select all records or would it have to be something amended in the query on the results page? Thanks in advance Steve Hello. I am having a hard time building my own search results page for my mysql database. Basically I am trying to search for game categories from the fldCategory field in the table, and display 15 results at a time in an HTML table with the Image of the games (fldIconMedium), and the titles of the games (fldTitle) placed in to the table. Also, at the bottom of the table would have a number bar that you can click on numbers to go to the next set of search results in the same page. The number bar would have Previous and Next button. For the code I am using, I had help from another expert. I thank him, but here is the code I have so far. =========================== =========================== <?php $cat=1; $nor=15; $a=1; if(isset($_GET['cat'])) { } else { $_GET['cat']=1; } echo $_GET['cat']; $con=mysql_connect("host","nusername","password") or die ("error"); $db=mysql_select_db("database",$con) or die("Database not found!"); $result=mysql_query("SELECT * FROM games") or die ("query error"); echo "<table border='1'><tr><th>ImageIcon</th><th>Title</th></tr>"; $r=mysql_num_rows($result); echo $r."<br/>"; $p=ceil($r/$nor); //echo $p; while($rows=mysql_fetch_array($result)) { if($a>($_GET['cat']-1)*$nor) { echo "<tr><td>".$rows['fldIconMedium']."</td><td>".$rows['fldTitle']."</td></tr>"; } $a=$a+1; } echo "</table>"; for($i=1;$i<=$p;$i++) { if($i==$_GET['cat']) { echo $i; } else { echo "<a href='gameslist.php?cat=".$i."'>".$i."</a>"; } } ?> =========================== =========================== To see this code in action, heres the link http://netroxy.com/gameslist.php?cat=skills. > Not working well. I am expecting the games search results page to look like this: http://netroxy.com/51274581336/search.htm So basically its: - viewing how many games found for game category, ex: Skills. Or Action, Mind, etc.. - the URL containing 'gameslist.php?cat=' with the given ID category at the end should search for that given category and display at least 15 games per results, along the number bar bellow, which counts how many are found from that category, which automatically increases or decreases the number bar bellow depending how many games from that specific category was found. I also forgot to mention that I did not add the Previous and Next button, which i dont know how - As for the 15 results per page, its basically 15 images (fldIconMedium) of different games of the same category, with their Titles (fldTitle) underneath them and both image and title should have the LINK to that specific game by retrieving the links from the 'fldLink' column where all the links of the games are found. Thanks all! Hello I have this code that searches multiple tables. running this query in the phpmyadmin page works fine and gives correct results. I echo-ed the $kw and noticed that it is lost (empty) when I click on Next (when moving to the second page or so..) How do I save the $kw for all search results? Thank you so much $kw = trim($_POST['keyword']); $kw = mysql_real_escape_string($kw); //Nomber of rows to display per page $page_rows=20; //This checks to see if there is a page number. If not, it will set it to page 1 if (!(isset($pagenum))) { $pagenum = 1; } echo "$kw of $pagenum"; //Count we count the number of results $data = mysql_query(" SELECT `id`,`title`, `body`, 'condoms_en' as REF FROM `condoms_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'discr_en' as REF FROM `discr_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'diseases_en' as REF FROM `diseases_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'express_en' as REF FROM `express_en` where `title` like '%$kw%' OR `body` like '%$kw%' ") or die(mysql_error()); $rows = mysql_num_rows($data); if ($rows ==1 || $rows > 1) { //echo "Number of rows $rows <br/>"; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //echo "<h4>".$pagenum."-20 of ".$total."results</h4> <br />"; // This shows the user what page they are on, and the total number of pages echo " ===> Page $pagenum of $last <br/><br/>"; //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query(" SELECT `id`,`title`, `body`, 'condoms_en' as REF FROM `condoms_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'discr_en' as REF FROM `discr_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'diseases_en' as REF FROM `diseases_en` where `title` like '%$kw%' OR `body` like '%$kw%' UNION SELECT `id`,`title`, `body`, 'express_en' as REF FROM `express_en` where `title` like '%$kw%' OR `body` like '%$kw%' $max") or die(mysql_error()); //This is where you display your query results while($info = mysql_fetch_array( $data_p )) { print $info['title']; //print $info['REF']; echo "<br>"; } echo "<p><br/>"; // 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) { } else { echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //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 style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a style=\"color: #FF0000\" href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } } //results was found else { echo "No results FOUND"; } I have a multiple choice search page which asks visitors to select one or more choices before rendering the search results. It only works in items 1+2 are selected, or 1+2+3, or 1+2+3+4, or 1+2+3+4, etc... I want to make it so that any combination of choices work. Example: Items 1+6 or 2+3+5 or 1+4+6 etc... I have four hours to fix it before my client shows up and need help BADLY. Anyone out there who can help? Whoever can help me... you are the best and I will have a special prayer for you tonight. Here is the coding: <?php } else{ if(!empty($_GET['latt']) && !empty($_GET['long'])) { $condition="SELECT ( 3959 * acos( cos( radians( '".$_GET['latt']."' ) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians( '".$_GET['long']."' ) ) + sin( radians( '".$_GET['latt']."' ) ) * sin( radians( latitude ) ) ) ) as distance,id,membership FROM notary_members "; if(!empty($_GET['s'])) { $a=" where and"; } else { $a=" where"; } if($_GET['edoc']!='') { $condition.=$a." edoc= 'yes'"; } if($_GET['esign']!='') { if($_GET['edoc']!='') $condition.=" and esign= 'yes'"; else $condition.=$a." esign= 'yes'"; } if($_GET['laserprinter']!='') { if($_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and laserprinter= 'yes'"; else $condition.=" laserprinter= 'yes'"; } if($_GET['dualtray']!='') { if( $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and dualtray= 'yes'"; else $condition.=" dualtray= 'yes'"; } if($_GET['error_in']!='') { if($_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and error_in= 'yes'"; else $condition.=" error_in= 'yes'"; } if($_GET['bg_checked']!='') { if($_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and bg_checked= 'yes'"; else $condition.=" bg_checked= 'yes'"; } if($_GET['home_insp']!='') { if($_GET['bg_checked']!='' || $_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and home_insp= 'yes'"; else $condition.=" home_insp= 'yes'"; } if($_GET['fingerprint']!='') { if($_GET['home_insp']!='' || $_GET['bg_checked']!='' || $_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and fingerprint= 'yes'"; else $condition.=" fingerprint= 'yes'"; } if($_GET['hosp_signing']!='') { if($_GET['fingerprint']!='' || $_GET['home_insp']!='' || $_GET['bg_checked']!='' || $_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and hosp_signing= 'yes'"; else $condition.=" hosp_signing= 'yes'"; } if($_GET['jail_signing']!='') { if($_GET['hosp_signing']!='' || $_GET['fingerprint']!='' || $_GET['home_insp']!='' || $_GET['bg_checked']!='' || $_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and jail_signing= 'yes'"; else $condition.=" jail_signing= 'yes'"; } if($_GET['im_docs']!='') { if($_GET['jail_signing']!='' || $_GET['hosp_signing']!='' || $_GET['fingerprint']!='' || $_GET['home_insp']!='' || $_GET['bg_checked']!='' || $_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='') $condition.=" and im_docs= 'yes'"; else $condition.=" im_docs= 'yes'"; } if($_GET['jail_signing']!='' || $_GET['hosp_signing']!='' || $_GET['fingerprint']!='' || $_GET['home_insp']!='' || $_GET['bg_checked']!='' || $_GET['error_in']!='' || $_GET['dualtray']!='' || $_GET['laserprinter']!='' || $_GET['esign']!='' || $_GET['edoc']!='' || $_GET['im_docs']!='') { $condition.=" and status=1 order by distance asc"; } else { $condition.=$a." status=1 order by distance asc"; } $sql=mysql_query($condition); $num=mysql_num_rows($sql); $getmile=explode(' ',$_GET['miles']); $c=0; while($getidres=mysql_fetch_array($sql)) { if($getidres['distance']<=$getmile[0]) { if($getidres['membership']=='premium') { $prefirst[$getidres['id']]=$getidres['distance']; $c++; } else { $basicfirst[$getidres['id']]=$getidres['distance']; $c++; } } } if(!empty($sql)) { if($c!=0) { if(!empty($prefirst) || !empty($basicfirst)) { ?> Hi all, I need your help as I have got a problem with display the 50 rows in the search results. I want to limit 50 rows in per page and if I have less than 50 rows like 21 rows in the page 2 then display the 21 rows. I have got a problem with the limit, because when I tried to use `LIMIT 0, 50`, it will display total 71 rows which I only want to display no more than 50 in per page. Here is what I have tried: $search_mailbox = $link->prepare("SELECT * FROM $folder WHERE from_email LIKE ? OR subject LIKE ? OR message LIKE ? ORDER BY received_date DESC LIMIT 0, 50"); $search_mailbox->execute([$searchemail, $searchsubject, $searchmessage]);
$search_mailbox = $link->prepare("SELECT * FROM $folder WHERE from_email LIKE ? OR subject LIKE ? OR message LIKE ? ORDER BY received_date DESC LIMIT $offset, $limit"); $search_mailbox->execute([$searchemail, $searchsubject, $searchmessage]);
Here is the full code:
<?php // Initialize the session session_start(); //Connect to the database require_once('config.php'); $searchemail = '%' . 'gmail.com' . '%'; $searchsubject = '%' . 'gmail.com' . '%'; $searchmessage = '%' . 'gmail.com' . '%'; $mailbox = $link->prepare("SHOW TABLES"); $mailbox->execute(); $folders = array(); $total = 0; $total_rows = 0; $i = 0; while ($folder = $mailbox->fetch(PDO::FETCH_NUM)) { $folder = $folder[0]; if (strpos($folder, 'users') !== false) { $folder = str_replace('users', '', $folder); } else { $folders[$i] = $folder; } $i++; } foreach($folders as $folder) { $search_mailbox = $link->prepare("SELECT * FROM $folder WHERE from_email LIKE ? OR subject LIKE ? OR message LIKE ? ORDER BY received_date DESC LIMIT 0, 50"); $search_mailbox->execute([$searchemail, $searchsubject, $searchmessage]); if ($search_mailbox->rowCount() > 0) { $total += $search_mailbox->rowCount(); } } $page = 1; $limit = 50; //$per_page = 50; //$pages = ceil($total / $per_page); $offset = ($page - 1) * $limit; foreach($folders as $folder) { $search_mailbox = $link->prepare("SELECT * FROM $folder WHERE from_email LIKE ? OR subject LIKE ? OR message LIKE ? ORDER BY received_date DESC LIMIT $offset, $limit); $search_mailbox->execute([$searchemail, $searchsubject, $searchmessage]); if ($search_mailbox->rowCount() > 0) { foreach($search_mailbox->fetchAll() as $k => $row) { $email_number = $row['id']; $search_from = $row['from_email']; $search_subject = $row['subject']; $total_rows++; echo $search_subject . '.........................' . $total_rows; echo "<br>"; } } } ?> I am unable to fetch the first 50 rows in the page 1 and I am also unable to fetch the 21 rows in the page 2. What I am trying to achieve is when I am in page 1, I want to display the first 50 rows, then in the page 2 if I have another 50 rows then display the 50 rows, but if I have less than 50 rows like 21 rows then display the 21 rows. Can you please show me an example how I can start with first 50 rows when I am in the page 1 then in page 2 display 21 rows to make in total 71 rows? Any advice would be much appreicated. Thanks in advance. Hello, I adapted the pagination script from the tutorial (great instruction and detail) from this site and it works perfectly. However, I added a search engine to it and it works like it should. The problem comes in with the following SQL query: Code: [Select] $sql = "SELECT COUNT(*) FROM qa"; If i modify it to fit my query, the number at the bottom of the page disappears and the > >> links go to blank pages. Also all queried rows show on one page and doesn't stop at ten. How do i modify my pagination script with a search engine so people can query their results without 'breaking' the pagination script?? This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=346243.0 Hi I'm new to the site... and new to PHP, so excuse me if my verbiage isn't quite right. I've been struggling to find a solution to paging through my search results. MY code works for the first five entries that are found via the mysql query but when I click next five results, the code breaks down and sends me back to my index. I believe the problem is he print " <a href=\"$PHP_SELF?s=$news&poster=$var\">Next 5 >></a>  "; I don't know how to rewrite, to display results based on the number of pages found. Ideally the user should be able to query the db and then page through the results. my entire code: Code: [Select] <?php // Get the search variable from URL $var = @$_GET['poster']; $trimmed = trim($var);//trim whitespace from stored variable // rows to return $limit=5; // check for empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; } else { // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database $con = mysql_connect("localhost", "test", "test") or die('Sorry, could not connect to server'); mysql_select_db("recipe", $con) or die('Sorry, could not connect to database'); //Build SQL Query $query = "Select date, poster, title, article FROM bulletin WHERE poster LIKE \"%$trimmed%\" order by articleid desc"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; } else // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; echo "<hr>"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $date = $row['date']; $poster = $row['poster']; $title = $row['title']; $article = $row['article']; echo "$date"; echo "<br>\n"; echo "<img src='images/marker.png'><font color=\"white\">$poster</font><br><br>\n"; echo "$title"; echo "<br />"; echo "<br />"; echo "<font color=\"white\">$article</font>\n"; echo "<br>\n"; echo "<hr>"; echo "<br>\n"; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 5</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; print " <a href=\"$PHP_SELF?s=$news&poster=$var\">Next 5 >></a>  "; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<br />"; echo "<br />"; echo "<p>Showing results $b to $a of $numrows</p>"; } ?> If someone could help I would be so great full! Thanks in advance... Mod edit: [code] . . . [/code] BBCode tags added. I would like to modify my php script where my PDF search results would not only display the company name, the country, but also display a limit number link by pages so that not all of the results are shown. I also want the first word searched to go to the first occurrence of the word on the PDF document. What would be the best way to do this? Here is my code: <html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (sco <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?> </p> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html> Any assistance would be greatly appreciated. Edited by mac_gyver, 15 May 2014 - 08:17 AM. code tags please Hello, Curious to know if someone could point me in the right direction, been struggling with this for a bit now. I have a HTML page with a search field, I can enter a search term and hit the submit button and I am directed to my search.php page with the appropriate results. What I am looking to accomplish is having the search results from the search.php page displayed in a text area below my search field in my HTML page. I have included an image to better describe what I am looking to accomplish: Additionally below is the source from my HTML page and search.php page: page.html <form name="search" action='search.php' method="post"> <input type="text" class="myinputstyle" name="search" value="search" onClick="this.value=''"/><br> <input type="submit" value="submit" class="myinputstyle"> </form> search.php <?php $search = "%" . $_POST["search"] . "%"; mysql_connect ("localhost", "game_over", "Ge7Ooc9uPiedee3oos9xoh4th"); mysql_select_db ("game_over"); $query = "SELECT * FROM game_over WHERE first_name LIKE '$search'"; $result = mysql_query ($query); if ($result) { while ($row = mysql_fetch_array ($result)) { echo "Name: {$row['name']} " . "{$row['lname']} <br>" . "Email: {$row['email]} <br>" . } } ?> Any insight would be most appreciated. Thank you. This is the code I have now however when you click next to view more results it says please enter a search..., (there is more code above this however I thought that the problem would be within the code provided.) $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> |