califdon: Thank you for the advice. I will add a choice for the user when they search.
AbraCadaver: I appreciate your tip. That is exactly what I will do!
What do you think of the current idea?
Code: Select all
$searchPieces = explode(" ",$search);
$year = NULL;
$searchTerm = "SELECT id,author1,keyword1,full reference,link FROM publications WHERE author1 LIKE '$search' AND keyword1 LIKE '$search'";
$searchTerm2 = "SELECT id,author1,keyword1,full reference,link FROM publications WHERE author1 LIKE '$search' OR keyword1 LIKE '$search'";
foreach($searchPieces as $val){
$val = trim($val);
if(strlen($val) == 4 && is_numeric($val)){
$searchTerm = $searchTerm . " AND year >= '$val'";
$searchTerm2 = $searchTerm . " AND year >= '$val'";
break;
}
}
$indexList = NULL;
$query2 = mysql_db_query("a2288820_data",$searchTerm);
while($row = mysql_fetch_row($query)){
$authorList = explode(",",$row[5]); //This is the array of authors
$keywordList = explode(",",$row[25]); //This is the array of keywords
$indexList[] = $row[0]; //This adds the index to an array to check later on for results that "aren't as good."
$fullReference = $row[3]; //This is the full reference string, not split into an array
$link = $row[4]; //This is the pdf link
/*
//Use this to iterate through the data if you need to
foreach($authorList as $val){
if(trim(strtolower($val)) == trim((strtolower($search)))) {
//result found
}
}*/
}
$query2 = mysql_db_query("a2288820_data","SELECT id,authors,keywords FROM publications WHERE authors LIKE '$search' OR keywords LIKE '$search'");
while($row = mysql_fetch_row($query2)){
if(array_search($row[0],$indexList) === FALSE){ //We haven't returned the results of this already
$authorList = explode(",",$row[5]);
$keywordList = explode(",",$row[25]);
$fullReference = $row[3]; //This is the full reference string, not split into an array
$link = $row[4]; //This is the pdf link
if(strlen($row[0]) > 0){
//Authors exists
}
else{
//Keywords exists
}
}
}
/*
$months = {"january","february","march","april","may","june","july","august","september","october","november","december"};
$searchPieces = explode(" ",$search);
$monthNum = -1;
foreach($searchPieces as $val){
if(($index = array_search(trim(strtolower($val)),$months)) !== FALSE){
$monthNum = $index + 1;
}
}*/
$query = mysql_db_query("a2288820_data","SELECT * FROM PUBLICATIONS");
while($row = mysql_fetch_row($query)){
$id = $row[0];
$authors = NULL;
for($i = 5; $i < 25; $i++){
if(strlen($row[i]) > 0){
$authors = $row[i] . ",";
}
}
$authors[strlen($authors) - 1] = "";
$authors = $row[5] . "," . $row[6] // do this in a for loop
$keywords = $row[25] . "," . $row[26] // keywords
echo $authors;
echo $keywords;
//mysql_db_query("a2288820_data","UPDATE PUBLICATIONS SET authors = '$authors' AND keywords = '$keywords' WHERE id = '$id'");
}
?>