hello
Server : Apache/2.4.52 (Ubuntu) System : Linux HAN2 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 User : servadmin ( 1000) PHP Version : 8.1.2-1ubuntu2.25 Disable Function : NONE Directory : /www/docs/video.obu.edu/Archives/scripts/ |
<?php
session_start();
//$con = mysql_connect("localhost","root","");
$con = mysql_connect("localhost","ATwebapp","quash2caj9pav");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
//select the database
mysql_select_db("LibraryArchives", $con);
//get the term that was searched for from the post variable
$searchTerm = $_POST["term"];
$ar = array();
$_SESSION['result']=null;
//first level search
$first = mysql_query("SELECT a.ArchDescriptionRepeatingDataId,r.resourceId, r.title, r.displayCreator, r.dateExpression, r.containerSummary, r.extentType, r.extentNumber, r.restrictionsApply FROM Resources AS r JOIN ArchDescriptionRepeatingData AS a ON r.resourceId = a.resourceId WHERE (r.title LIKE '%" . $searchTerm . "%' OR a.noteContent LIKE '%" . $searchTerm ."%' OR displayCreator LIKE '%" . $searchTerm . "%') AND (a.title LIKE '%Bio%' OR a.title LIKE '%Scope%') GROUP BY r.resourceId");
$count=0;
//if there are search results
if(isset($first))
{
while($row = mysql_fetch_array($first))
{
$ar[$count]=$row;
$count+=1;
}
//to do implement piece wise search "yellow" + "car"
//go through each resource id and get the scope and content from the database in order for it to be displayed on the the dropdown area of the search result
for($i=0;$i<$count;$i++)
{
//get the result from the database for this particular resourceId where the ADRD title is Scope and Contents
$result = mysql_query("SELECT a.noteContent FROM ArchDescriptionRepeatingData AS a WHERE resourceId = '". $ar[$i]['resourceId'] . "' AND title LIKE '%Scope%'") ;
while($row = mysql_fetch_array($result))
{ //save the note content into the php array that is storing the search results
$ar[$i]['noteContent']=htmlentities($row['noteContent'],ENT_IGNORE,'utf-8');
}
}
//save the array of search results into the session
$_SESSION['result']=$ar;
}
//close the db connection and redirect to the index page
mysql_close($con);
header('Location: ../index.php?display=0');
?>