Hey guys,
The search code below works for pulling document info and descriptions out of my database. The issue is, that sometimes, if the search term is vague, it will pull multiple results. That can get somewhat messy when there are a ton of results, I would like to see if there is some modification I could do to have the document name turn into a link that can be clicked on to only show that result. Any thoughts?
[php]
table {
border-collapse: collapse;
border: solid 1px black;
}
td {
padding: 2px 6px;
border: solid 1px black;
}
Search for:
<?php if(isset($_POST['search'])) { $connx = mysql_connect('localhost', '*****', '*****') or die("connx"); $db = mysql_select_db('dvetter_sugarce') or die(mysql_error()); # convert to upper case, trim it, and replace spaces with "|": $search = (ini_get('magic_quotes_gpc')) ? stripslashes($_POST['search']) : $_POST['search']; $search = mysql_real_escape_string($search); $search = strtoupper(preg_replace('/\s+/', '|', trim($_POST['search']))); # create a MySQL REGEXP for the search: $regexp = "REGEXP '[[:<:]]($search)[[:>:]]'"; $query = "SELECT document_name, description FROM `documents` WHERE UPPER(`description`) $regexp OR ". "`document_name` $regexp"; $result = mysql_query($query) or die($query . " - " . mysql_error()); echo "$value | "; } echo "