yobo Posted March 13, 2008 Share Posted March 13, 2008 Hey all, Umm how would i link a serach result to the download page but the search result must download the specfic file that was searched for in the serach box if you get what i mean, i thought about using the id of that file name here is my coding so far <?php /*set varibles from form */ $searchterm = $_POST['searchterm']; trim ($searchterm); /*check if search term was entered*/ if (!$searchterm){ echo 'Please enter a search term.'; } /*add slashes to search term*/ if (!get_magic_quotes_gpc()) { $searchterm = addslashes($searchterm); } /* connects to database */ @ $dbconn = new mysqli('localhost', 'root', '', 'uploads'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } /*query the database*/ $query = "select id, name from upload where name like '%".$searchterm."%'"; $result = $dbconn->query($query); /*number of rows found*/ $num_results = $result->num_rows; echo '<p>Found: '.$num_results.'</p>'; /*loops through results*/ for ($i=0; $i <$num_results; $i++) { $num_found = $i + 1; $row = $result->fetch_assoc(); echo "<a href='download.php?id=$id > $num_found.".($row['name'])."<br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/95967-download-link-problem/ Share on other sites More sharing options...
yobo Posted March 13, 2008 Author Share Posted March 13, 2008 anyone able to help please Link to comment https://forums.phpfreaks.com/topic/95967-download-link-problem/#findComment-491304 Share on other sites More sharing options...
BlueSkyIS Posted March 13, 2008 Share Posted March 13, 2008 do you have a question or error? Link to comment https://forums.phpfreaks.com/topic/95967-download-link-problem/#findComment-491319 Share on other sites More sharing options...
Lashiec Posted March 13, 2008 Share Posted March 13, 2008 Try... echo '<a href="download.php?id='.$id.'">'.$row['name'].'</a><br />'; For your download link. I'm really not sure what you're trying to do with your link, but the $id > $num_found looks like a problem area to me. Also not closing the <a> tag. Link to comment https://forums.phpfreaks.com/topic/95967-download-link-problem/#findComment-491372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.