Jump to content

rodhow

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rodhow's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. basically when someone enters a search word, if it matches whats in the tag column, the query kicks out the link on a search results page. For the qa table, it is set up with a id, q#, question, link, answer and tags. In the mlb table, it is id2,q#2,question2,link2, answer2 and tags2. Field names tags(qa) and tags2(mlb) has search terms corresponding to the link they are search for. For instance, if someone puts in NFL, then all the links with the tag nfl will print on the search results page. Again, this works for the qa table but I have other tables im now filling up and want to join it on one search page. qa table id q# question linkans answer tags mlb table id2 q#2 question2 link2an answer2 tags 2 Hope this illustrates it more effectively...thanks
  2. the data (links) are displayed as search results. from one table (qa) I am getting what i want to be displayed...but I have another table (mlb), basically set up the same way that I'm having problems combining into the query that already works. The differences is the data i.e. qa link is questions for one set of athletes (who (nlf) was born on this day) and in the mlb table under link2 is for another set (who (mlb) was born on this day)...I want it all to flush out on my search results page..Thanks for the help
  3. Hello, I combined both of the suggestions and keep getting a fatal error...this is one of several queries I tried but didn't work. $sql = "SELECT qa.link, mlb.link2 FROM qa INNER JOIN mlb ON qa.id = mlb.id (<--- don't really understand this part) WHERE qa.tags LIKE '%$trimmed%' LIMIT $offset, $rowsperpage AND mlb.tags2 LIKE '%$trimmed%' LIMIT $offset, $rowsperpage"; tried it without the INNER JOIN, ON qa.id=mlb.id and also tried qa.tags AND mlb.tags2 LIKE '%$trimmed%' LIMIT $offset, $rowsperpage . I also tried the UNION but was unsuccessful. Help lol
  4. hello, I am trying to join multiple tables to print out links as search results on a page. So far one table is fine but when I try to add the second table, i get an error message. I have two tables (qa and mlb) and I get search results from keywords that match tags in qa table, but the error message comes when I add tags2 from mlb table. heres the query $sql = "SELECT qa.link, mlb.link2 FROM qa, mlb WHERE qa.tags, mlb.tags2 LIKE '%$trimmed%'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); There is another query as well which gets me my rows from search results that is probably having the same problems... $sql = "SELECT COUNT(*) FROM qa, mlb WHERE qa.tags, mlb.tags2 LIKE '%$trimmed%'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); Here is a query with one table that works... $sql = "SELECT COUNT(*) FROM qa WHERE tags LIKE '%$trimmed%'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
  5. Hello, I am a novice at PHP and I have a quick question. I am trying to pull a title and change the keywords in the meta tags dynamically by using information from a database. How do I query my database specifically for these actions and what do i put on the landing page. for example <title> <?php echo 'title' ?></title> or something of that nature? Thanks in advance.
  6. Hello all, I am having a bit of trouble with this contact form. Everything submits fine, errors work and all but the information isn't sent to my inbox. Can anyone point out where the problem is? Thanks in advance! if(isset($_POST['Email_Address'])) { include 'free_settings.php'; function died($error) { echo "Sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } if(!isset($_POST['Full_Name']) || !isset($_POST['Email_Address']) || !isset($_POST['Your_Message'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $full_name = $_POST['Full_Name']; // required $email_from = $_POST['Email_Address']; // required $comments = $_POST['Your_Message']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(preg_match($email_exp,$email_from)==0) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($full_name) < 2) { $error_message .= 'Your Name does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\r\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\r\n"; $email_message .= "Email: ".clean_string($email_from)."\r\n"; $email_message .= "Message: ".clean_string($comments)."\r\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); header("Location: $thankyou"); ?> <script>location.replace('<?php echo $thankyou;?>')</script> <?php
  7. I want to apologize. It was an error on my part. I put the code in correctly and now it works, thank you PFMaBiSmAd for your expertise! I couldn't have figured it out without ur help!
  8. Hello, I replaced the code and inserted your code and now there is no pagination (< << prev,next,>> >) showing up at the bottom now. I am so lost right now. What am I doing wrong?
  9. can anyone see what is wrong with the query statement(s) at all, if that is the problem?
  10. okay here is the entire code with the part in question near the top. This works perfectly: $sql = "SELECT COUNT(*) FROM qa"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result);$numrows = $r[0]; $rowsperpage = 10; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT link FROM qa LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); while ($list = mysql_fetch_assoc($result)) { echo $list['link'] . " " . $list['number'] . "<br />"; } $range = 3; if ($currentpage > 1) { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } ?> Now this is the part where I added the search engine, some error checks and changed the sql query which seems to break the pagination. I fixed the number count by keeping the SELECT COUNT in the first query and the variables in the second query. The only problem now is that if I have more than one page (11 records or more) the next pages as well as the > >> links return blank pages. I guess its now how can I access the remaining records: <form name="form" action="pagination2.php" method="get"> <input type="text" name="keywords" /> <input type="submit" name="Submit" value="Search" /> </form> <?php $var = @$_GET['keywords'] ; $trimmed = trim($var); if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } $sql = $sql = "SELECT COUNT(*) FROM qa WHERE tags LIKE '%$trimmed%'"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result);$numrows = $r[0]; echo "<p>You searched for: "" . $var . ""</p>"; $rowsperpage = 10; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT link FROM qa WHERE tags LIKE '%$trimmed%' LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); echo "<table>"; while ($list = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td>" . $list['link'] . "</td>"; echo "</tr>"; } echo "</table>"; $range = 3; if ($currentpage > 1) { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } ?>
  11. 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: $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??
  12. Okay thanks...to both of you. I wasn't sure about the unique ID but now I am. I didn't create those in the links and the two of you pointed me into a great direction. Got the results I was looking. Thanks and this problemd has been SOLVED!
  13. Hello, I am about to upload records into my mysql database that will easily total into the thousands. Each row represents a page so when someone searches for information, the search page displays the requested rows as links. However, I haven't started making the files yet to these links as I would have to create one for every row. Is there an alternative to this madness? Is there a dynamic page script that would display information from that row when the link is clicked on? Can someone point me in the right direction via tutorial, or just give me some information on how to do this. I would not want to make thousands of individual pages; the maintenance would be disastrous. Thanks.
  14. yes the script does return the proper number of records. I get ten records on the first page displaying '1 to 10 of x number of records' at the bottom with tne next 10 link appearing but when I click it, it doesn't show the rest of records plus displays a blank page with just a search box. This is the query used $query .= "limit $s,$limit"; $result = mysql_query($query) or die($query."|".mysql_error());
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.