Jump to content

Download Link problem


yobo

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.