PHP - Quick Question On Creating Link For Php Search
Hello, all I know this isn't actually a PHP questions, but I thought you guys might be able to help. I am creating a software for a forum and would like to create a link to search for a tag word that can link to a search that can find the software. The website uses this for search: https://www.website.com/search.php?do=process I figured out this works to put the keyword in the tag box: https://www.website.com/search.php?tag=mysearchword I can't figure out how to combine the two to process the search. I tried things like this: https://www.website.com/search.php?do=process&tag=mysearchword But that and other variations did not work. Does anyone have any suggestions? Thanks! Edited July 5, 2019 by abberrationadded more info Similar TutorialsHere is the function sources that calls the social communtiy re-route or re-direct. an you tell me how to re-write that line alone,pls Code: [Select] function getReturnURL() { $regType = XiptFactory::getSettings('user_reg'); if($regType === 'community') // return XiPTRoute::_('index.php?option=com_community&view=register', false); return XiPTRoute::_('index.php?option=com_community&view=register&Itemid=436', false); //return XiPTRoute::_('index.php?option=com_user&view=register', false); return XiPTRoute::_('index.php?option=com_community&view=register&Itemid=436', false); } Quote from: danjapro I need some quick help. I just need to write this redirect out to where it only redirect the link I have. Current State, NO GOOD producing two itemids. Code: [Select] return XiPTRoute::_('index.php?option=com_community&view=register&Itemid=436', false); I just want the url I have listed to be in url, not any addtional itemids. Thank you in advance. Hello, Does anyone know a tutorial I can follow to create my own search engine over the items I have in my SQL database? I find a lot of tutorials but they are all 'one word searches' which means if you type two words you will get all results that contain either word (too many hits). If the search engine tutorial displays result with AJAX even better. Thanks for help. df Hello. I am working on a php script for searching a database table. I am really new to this, so I used the this tutorial http://www.phpfreaks.com/tutorial/simple-sql-search I managed to get all the things working the way I wanted, except one important and crucial thing. Let me explain. My table consist of three columns, like this: ID(bigint20) title(text) link (varchar255) ============================= ID1 title1 link-1 ID2 title2 link-2 etc... Like I said, I managed to make the script display results for a search query based on the title. Want I want it to do more, but I can't seem to find the right resource to learn how, is to place a "Download" button under each search result with its corresponding link from the table. Here is the code I used. <?php $dbHost = 'localhost'; // localhost will be used in most cases // set these to your mysql database username and password. $dbUser = 'user'; $dbPass = 'pass'; $dbDatabase = 'db'; // the database you put the table into. $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error()); mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error()); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 3) { $error[] = "Search terms must be longer than 3 characters."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT title, link FROM db WHERE title LIKE '%{$searchTermDB}%'"; $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$row['title']}<br /> Download - this is the button I want to link to the title results - and maybe other links too - <br /> "; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="search?" name="searchForm"> Search for title: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /> <input type="submit" name="submit" value="Search" /> </form> <?php echo (count($results) > 0)?"Rezultate lucrari de licenta sau disertatie pentru {$searchTerms} :<br /><br />" . implode("", $results):""; ?> $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$row['title']}<br /> Download - this is the button I want to link to the title results - and maybe other links too - <br /> "; $i++; I would like the results to be displayed like this Results for SearchItem: Result 1 Download | Other link Result 2 Download | Other link etc.... or something like this. So, how do I add the data from the link row into a text(Dowload), within an <a href> tag (well, at least I guess it would go this way) ? My first tries (fueled by my lack of knowledge) where things like $results[] = "{$row['title']}<br /> <a href="{$row['link']}">Download</a> <br /> "; but I keep getting lots of errors, and then I don't know much about arrays and stuff (except basic notions); So there it is. I am really stuck and can't seem to find any workaround for this. Any suggestions? (examples, documentation, anything would do, really) Thanks, Radu $link = ?><a href="post?id=<?php echo $id; ?>&title=<?php echo $slug_title; ?>"><?php echo $title; ?></a><?phpBasically what I am trying to do is get a url link of a current page that I'll be sending in an email. I have all the $_GET variables I need to duplicate the current url. For some reason it's giving me an error. Can you please fix what is shown above into something that'll work? Thanks. Edited by man5, 15 July 2014 - 07:09 PM. hi. when i get into some function manual and there is a note says. Quote This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. . is that meaning that after 5.3.0 version this function will not be supported? thanks , Mor. I am starting to learn PDO by re-writing one of my existing scripts. Do I still need to validate $_GET or does PDO do the work for me? Currently I am using: Code: [Select] $id = $_GET['id']; $sth = $dbh->prepare('DELETE FROM van_reservations WHERE id = :id'); $sth->bindParam(':id', $id, PDO::PARAM_INT); $sth->execute(); I used to validate by using this: Code: [Select] $id = isset($_GET['id']) && is_numeric($_GET['id'])?(int) $_GET['id']:0; hey guys i have a script that creates a cookie named "MyLoginPage" now everything works well the cookie is saved and it keeps the user logged in The Question ok so im wanting to create a link that will delete the cookie so when the user clicks the link it will delete the cookie is this possible?? if so, how?? many thanks how to open a site with curl that has frames ? when ive tried it gives "your broswer does not support frames" ... Is there a way to only output the first, say, 30 words of a variable? I have a way to do it in mind, but seems like it's messy and not practical. Any suggestions? E.g: WITHOUT LIMIT: Welcome to my store. Would you like to buy something? We have really good noodles and fishes in doodle pools. WITH LIMIT: Welcome to my store. Would you like... Sort of like a short preview. What is the difference between these two lines Code: [Select] !isset($_POST[$requiredField]) and Code: [Select] !$_POST[$requiredField] hey! I have a site where I want to use multiple issets at the same time, like if I have four buttons and four issets: if(isset($_POST['one'])) { echo '<div class="example_box">one</div>'; } if(isset($_POST['two'])) { echo '<div class="example_box">two</div>'; } if(isset($_POST['three'])) { echo '<div class="example_box">three</div>'; } if(isset($_POST['four'])) { echo '<div class="example_box">four</div>'; } but for some reason it seems like only one isset can be activate at a time, is there any way to work this out or something :s? I've tried some variants of elseif stuff and such, but yeah, I'm pretty new at this stuff Does storing multiple values in 1 database field with a varchar let's say set at 150, all separated by "|'s" so I don't have to create a field name for each one is it better performance wise or no? (storing 6-7 different |'s that will be outputted with a array ofc) ? Hi, I've seen code like this multiple times, but I don't really know what it means. function funcName(&$something) { // whatever } What exactly does the "&" do before the variable? code <?php //storecodefound.php v1.0 //purpose is to store the http refer and the code associated with the site to a db to be collected and verified by submitcode.php $code = $_GET['code']; $site = $_SERVER['HTTP_HOST']; //check to see if the code already present $connect = mysql_connect("localhost","root","") or die (mysql_error()); $check = mysql_query("SELECT code FROM hunter.codes WHERE code='$code'") or die (mysql_error()); $row = mysql_num_rows($check); echo "result of \$row is ".$row; echo "<br />"; if ($row = 0) { //insert into db cause it's not there mysql_query("INSERT INTO hunter.codes (id, code, site) VALUES ('','$code','$site')") or die (mysql_error()); } else { //echo it's already here echo "Code already found on server!"; } ?> my question is the result of $row is infact 0 and the if statement says if $row is 0 to insert into db and instead it's given me the code is already found? I need to use a HTML form to retrieve data in a certain order of ascending/descending using a drop down box and a true/false statement button for one of the values from a MySQL database. Im guessing I need a php script to query the database, but can I add the php code to the HTML or upload a php to the server that links the HTML thank you Hi guys, I was wondering if we have table of seats in a cinema (which makes the quantity to 1) and two users are booking the same seat at the same time on our application. How can we prevent that? I though if we create a session or even update that seat row and then if user doesn't finish the booking/or leave the browser on fora while in 10-15 minutes, that session still remains on. I'm sure we can expire that session how can we prevent both users have the same session and if one doesn't complete the purchase for any reason then how session can automatically update the database after that 15 minutes? Thanks in advance. I have data that is in a form right now being displayed in a textbox because I want the user to see the 'name' but the data that needs to be passed when submit is pressed is the id of the entity. So if I have <label id = "username" Value = "3"> Heintzman</label> can I use $_Post to retrieve that value once the form has been submitted because I dont want the data to be displayed in a textbox it looks ugly and isnt long enough for the text without editing. Hi I have a quick question. I want my javascript to be able to access my php page because my php page has the coding to access the database and then it has to give me a list of the stuff in the database the alert box. This is the code that I have. I know that I can use it but I'm not sure how to go about it. getPHPResponse=function(){ var url="/countries/ajax_return_response"; $.post(url, {'format': 'JSON', 'countries': '$countries'}, function(data){ //this is where jsvascript must do something alert(data); }); } Hello everyone, With the recent time change, I found a new problem with my code. I think I have it fixed by utilizing the "date_default_timezone_set()" function, but I have a question. Does this php time/date function automatically account for daylight savings time, is it something that will have to be adjusted in my code? I think I can figure out how to adjust it if it's needed, but I don't want to have to do the work if it is updated automatically. Thanks for any help. Hi guys/girls, any pointers on this would be greatly appreciated. basically i have a table called HORSES with 2 fields: HORSE_ID and HORSE_NAME. I want to create a page which dynamically shows all the horse ID's, then a checkbox, then the horse names which can be edited. You can then edit a horse name, click the edit checkbox, and post the form to edit the database. The Form shows the fields easily enough, but doesnt update the database for some reason. Anyone got any ideas? <?php include("..\connection\connection.php"); $conn = oci_connect($UName,$PWord,$DB) or die("Couldn't logon."); if(empty($_POST["check"])) { $query = "SELECT * FROM HORSE ORDER BY HORSE_NAME"; $stmt = oci_parse($conn,$query); oci_execute($stmt); ?> <form method="post" action="horsemultiple.php"> <table border="1" cellpadding="5"> <tr> <th>Horse_ID</th> <th>Edit</th> <th>Horse Name</th> </tr> <?php while ($namearray = oci_fetch_array ($stmt)) { ?> <tr> <td><?php echo $namearray["HORSE_ID"]; ?></td> <td align="center"> <input type="checkbox" name="check[]" value="<?php echo $namearray["HORSE_ID"]; ?>"> </td> <td align="center"> <input type="text" size="5" name="<?php echo $namearray["HORSE_ID"]; ?>" value="<?php echo $namearray["HORSE_NAME"]; ?>"> </td> </tr> <?php } ?> </table><p /> <center> <input type="submit" value="Update Selected Horses"> </center> </form> <?php oci_free_statement($stmt); } else { foreach($_POST["check"] as $id) { $query = "UPDATE HORSE set HORSE_NAME = ".$_POST[$id]. " WHERE HORSE_ID ='".$id."'"; $stmt = oci_parse($conn,$query); oci_execute($stmt); header("location: ../horse.php"); } } oci_close($conn); ?> |