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 />"; } ?> Quote Link to comment Share on other sites More sharing options...
yobo Posted March 13, 2008 Author Share Posted March 13, 2008 anyone able to help please Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 13, 2008 Share Posted March 13, 2008 do you have a question or error? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.