I have this function below. It outputs each line of a Mysql DB. Each line is a path to a file.
e.g.
/Volumes/02_SERVER/GRADE/GRADE_10/Test Me/978079 G10 English/downloads/revision-tests
It works fine. But what I want is to make it linkable.
I have tried this sort of thing:
echo "<a file='" . $o . "' ></a>";
But it does not work
All the Code:
<?php
require_once 'db.php';
// Output HTML formats
$html = '<tr>';
$html .= '<td class="small">nameString</td>';
$html .= '</tr>';
// Get the Search
$search_string = preg_replace("/_-[^A-Za-z0-9]/", " ", $_POST['query']);
$search_string = $test_db->real_escape_string($search_string);
// Check if length is more than 1 character
if (strlen($search_string) >= 1 && $search_string !== ' ') {
//Insert Time Stamp
$query = 'SELECT * FROM live_table WHERE name LIKE "%' . $search_string . '%"';
//Timestamp entry of search for later display
$time_entry = $test_db->query($time);
//Count how many times a query occurs
$query_count = $test_db->query($query_count);
// Do the search
$result = $test_db->query($query);
while ($results = $result->fetch_array()) {
$result_array[] = $results;
}
// Check for results
if (isset($result_array)) {
foreach ($result_array as $result) {
// Output strings and highlight the matches
$d_name = preg_replace("/" . $search_string . "/i", " <b>" . $search_string . "</b>", $result['name']);
$d_comp = $result['company'];
// Replace the items into above HTML
$o = str_replace('nameString', $d_name, $html);
// Output it
echo ($o);
}
} else {
// Replace for no results
$o = str_replace('nameString', '<span class="label label-danger">No Data Found</span>', $html);
// Output
echo($o);
}
}
?>