applebiz89 Posted April 15, 2009 Share Posted April 15, 2009 As it stands; I can search the database with a given word in the form, and it will bring back all the files that, that word is in. However I want to after finding all the files with the word in, give a link to them files to view. How could I go about doing this. This is my searcher file code. ------------------------------------------------------------- $var = @$_POST['input'] ; $trimmed = trim($var); //trim whitespace from the stored variable $limit=10; if (!get_magic_quotes_gpc()) { $var = addslashes($var); } $query = "SELECT filename FROM webdata WHERE words LIKE '%" .$var."%' order by filename"; $result = mysql_query($query); echo "<p>You searched for: "" . $var . ""</p>"; $num_results = mysql_num_rows($result); echo '<p>Found: ' .$num_results; '</p>'; for ($i=0; $i <$num_results; $i++) { $num_found = $i + 1; $row = mysql_fetch_assoc($result); echo "$num_found. " .($row['filename']). "<br/>"; } Link to comment https://forums.phpfreaks.com/topic/154207-a-href-need-to-link-files-from-data-base-help-please/ Share on other sites More sharing options...
Maq Posted April 15, 2009 Share Posted April 15, 2009 Looks like your adding 2 to $num_found because you have $i++ in the loop then you add one again within the loop. For a link, try something like: echo "$num_found {$row['filename']} "; Link to comment https://forums.phpfreaks.com/topic/154207-a-href-need-to-link-files-from-data-base-help-please/#findComment-810689 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.