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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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