Hi, wondering can I get some help here please as this is incredibly frustrating. I have a database that contains files and I want to be able to search those files by putting in a ID number. In my databse my doc_id is the primary key, and I want the user to be able to enter a document ID and have all the information returned to them.
Can anyone help me here as I don't understand why it isn't working? When I enter a document ID into my search page I get the same result each time which is document number 338 for example.
<?php
///-----------------------------
/// Inserting data into database
///-----------------------------
include 'connect_db.php';
include 'newheader.php';
function sanitize_data($data)
{
$data = array_map('trim',$data);
$data = array_map('strip_tags',$data);
$data = array_map('htmlspecialchars',$data);
$data = array_map('mysql_real_escape_string',$data);
return $data;
}
$post = sanitize_data($_POST);
if ($_POST['searchID'])
{
$searchById = "SELECT * FROM tc_tool.forms WHERE doc_id LIKE '%$doc_id%'";
$result = mysql_query($searchById);
$row = mysql_fetch_assoc($result);
if (!mysql_query($searchById, $connection))
{
echo "Query failed: $query<br />" . mysql_error() . " <br /><br /> ";
}
echo $row ['doc_id'] . " <br /> "
. $row ['doc_title'] . " <br /> "
. $row ['doc_number'] . " <br /> "
. $row ['doc_type'] . " <br /> "
. $row ['revision'] . " <br /> "
. $row ['cdm_link'] . " <br /> "
. $row ['mars_link'] . " <br /> "
. $row ['checklist_link'] . " <br /> "
. $row ['link_internal_1_3']. " <br /> "
. $row ['impacted_products']. " <br /> "
. $row ['scope']. " <br /> "
. $row ['impacted_products_2'] ." <br /> "
. $row ['review_class']. " <br /> "
. $row ['full_simplified'] . " <br /> "
. $row ['pref_earliest'] . " <br /> "
. $row ['pref_latest'] . " <br /> "
. $row ['prev_reviews'] . " <br /> "
. $row ['proj_name'] . " <br /> "
. $row ['auth_name'] . " <br /> "
. $row ['req_list'] . " <br /> "
. $row ['optional_list'] . " <br /> "
. $row ['information_only'] . " <br /> "
. $row ['chairperson'] . " <br /> "
. $row ['req_reviewers'] . " <br /> "
. $row ['review_duration'] . " <br /> "
. $row ['document_abstract'] . " <br /> ";
echo "<br / >";
}
?>
<?php include "footer.php" ?>