How do I fix that?
Code: Select all
<?php
$indexCheck = "yes";
require('config.php');
session_start();
if(@$_SESSION['log'])
@$userCheck = "admin";
$sort1 = @$_GET['sort'];
$search = @$_GET['search'];
$sortBy = @$_GET['by'];
//advanced search output by AUTHOR
if($sort1 == "Author")
{
$authors = array();
$i = 0;
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author1") or die(mysql_error());
while((@@$row = mysql_fetch_array($result)))
{
if(@$row[5] != ""){
if(!in_array(@$row[5],$authors)){
$authors[$i] = @@$row[5];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author2");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[6] != ""){
if(!in_array(@$row[6],$authors)){
$authors[$i] = @@$row[6];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author3");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[7] != ""){
if(!in_array(@$row[7],$authors)){
$authors[$i] = @@$row[7];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author4");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author5");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[9] != ""){
if(!in_array(@$row[9],$authors)){
$authors[$i] = @@$row[9];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author6");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author7");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author8");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author9");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author10");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[10] != ""){
if(!in_array(@$row[10],$authors)){
$authors[$i] = @@$row[10];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author11");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author12");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author13");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author14");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author15");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY author16");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[8] != ""){
if(!in_array(@$row[8],$authors)){
$authors[$i] = @@$row[8];
$i++;
}
}
}
echo "<select onChange=\"javascript: if (this.value != 'NULL') { searchBase(this.value,'$sort1')}\">";
echo "<option value=\"NULL\">Choose an author to search by </option>";
for($b=0;$b<sizeOf($authors);$b++)
{
echo "<option value=\"$authors[$b]\">$authors[$b]</option>";
}
echo "</select>";
}
//advanced search output by KEYWORD
if($sort1 == "Keyword")
{
$keyword = array();
$i = 0;
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword1");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[24] != ""){
if(!in_array(@$row[24],$keyword)){
$keyword[$i] = @@$row[24];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword2");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[25] != ""){
if(!in_array(@$row[25],$keyword)){
$keyword[$i] = @@$row[25];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword3");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[26] != ""){
if(!in_array(@$row[26],$keyword)){
$keyword[$i] = @@$row[26];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword3");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[27] != ""){
if(!in_array(@$row[27],$keyword)){
$keyword[$i] = @@$row[27];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword3");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[28] != ""){
if(!in_array(@$row[28],$keyword)){
$keyword[$i] = @@$row[28];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword3");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[29] != ""){
if(!in_array(@$row[29],$keyword)){
$keyword[$i] = @@$row[29];
$i++;
}
}
}
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY keyword3");
while((@$row = mysql_fetch_array($result)))
{
if(@$row[30] != ""){
if(!in_array(@$row[30],$keyword)){
$keyword[$i] = @@$row[30];
$i++;
}
}
}
echo "<select onChange=\"javascript: if (this.value != 'NULL') { searchBase(this.value,'$sort1')}\">";
echo "<option value=\"NULL\">Choose a keyword to search by </option>";
for($b=0;$b<sizeOf($keyword);$b++)
{
echo "<option value=\"$keyword[$b]\">$keyword[$b]</option>";
}
echo "</select>";
}
//advanced search output by DATE
if($sort1 == "Date")
{
$d2 = array();
$ia = 0;
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY year");
echo "<select onChange=\"javascript: if (this.value != 'NULL') { searchBase(this.value,'$sort1')}\">";
echo "<option value=\"NULL\">Choose a year to search by </option>";
while((@$row = mysql_fetch_array($result)))
{
if((@$row[2] != "")){
if(!in_array(@$row[2],$d2)){
$temp = @@$row[2];
$d2[$ia] = $temp;
$ia++;
}
}
}
rsort($d2);
for($ia=0;$ia<sizeOf($d2);$ia++)
echo "<option value=\"$d2[$ia]\">".$d2[$ia]."</option>";
echo "</select>";
}
//advanced search output by TYPE
if($sort1 == "Type")
{
$d2 = array();
$ia = 0;
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY type");
echo "<select onChange=\"javascript: if (this.value != 'NULL') { searchBase(this.value,'$sort1')}\">";
echo "<option value=\"NULL\">Choose a type to search by </option>";
while((@$row = mysql_fetch_array($result)))
{
if((@$row[1] != "")){
if(!in_array(@$row[1],$d2)){
$temp = @@$row[1];
$d2[$ia] = $temp;
$ia++;
}
}
}
for($ia=0;$ia<sizeOf($d2);$ia++)
echo "<option value=\"$d2[$ia]\">".$d2[$ia]."</option>";
echo "</select>";
}
//advanced search output by FULL REF THAT IS NOT WORKING
if($sort1 == "Standard Reference")
{
$d2 = array();
$ia = 0;
$result = mysql_db_query("a2288820_data","SELECT * FROM publications ORDER BY stadRef");
echo "<select onChange=\"javascript: if (this.value != 'NULL') { searchBase(this.value,'$sort1')}\">";
echo "<option value=\"NULL\">Choose a Type to search by </option>";
while((@$row = mysql_fetch_array($result)))
{
if((@$row[12] != "")){
if(!in_array(@$row[12],$d2)){
$temp = @@$row[12];
$d2[$ia] = $temp;
$ia++;
}
}
}
for($ia=0;$ia<sizeOf($d2);$ia++)
echo "<option value=\"$d2[$ia]\">".$d2[$ia]."</option>";
echo "</select>";
}
function echoSearchResultsTableHeader() {
echo "<tr id=\"topRow\">";
echo "<th>ID</th>";
echo "<th>Primary author</th>";
echo "<th>Secondary author</th>";
echo "<th width=65%>Standard Reference</th>";
echo "<th>Link</th>";
echo "</tr>";
}
//construct query
function echoSearchResultsTableRows($search,$sortField,&$startIndex) {
$trimmed=trim($search);
$result = mysql_query("select * from publications where $sortField like \"%$trimmed%\" order by $sortField");
echoMysqlSearchResultsTableRows($result,$startIndex);
}
function echoMysqlSearchResultsTableRows($result,&$startIndex) {
$index = $startIndex;
while(@$row = mysql_fetch_array($result))
{
echo "<tr>\n";
if(@$userCheck == "admin"){
echo "<td id=\"noLinkTd\"><a href=\"?page=edit&cID=".$row[0]."\">[Edit] ".$z."</a><br />";
echo " <a href=\"javascript://\" onClick=\"deleteRow(".$row[0].",".$z.")\">[Remove]</a>";
echo "</td>\n";
}
else
echo "<td><b>".$row['id']."</b></td>\n";
echo "<td align=center>".$row[5]." </td>\n";
echo "<td align=center>".$row[6]." </td>\n";
echo "<td>".$row[35]." </td>\n";
echo "<td><a href=\"".$row[36]."\">".$row[36]."</a> </td>\n";
echo "</tr>\n";
$index++;
}
$startIndex = $index;
}
if(($search != null))
{
echo "<div id=\"sfor\">";
echo "Searching for... ";
echo "<b>".$search."</b>";
echo "<div id=\"back\">";
echo "<a href='http://agecon2.tamu.edu/people/faculty/rister-edward/dev/?page=view';>Return to full database</a>";
echo "</div>";
echo "</div>";
echo "<div class=\"database\">";
echo "<table class=\"sortable2\" cellspacing=\"0\" id=\"dataTable\">";
echoSearchResultsTableHeader();
$index = 0;
if($sortBy == "Date")
{
echoSearchResultsTableRows($search,"year",$index);
}
if($sortBy == "Standard Reference")
{
echoSearchResultsTableRows($search,"stadRef",$index);
}
if($sortBy == "Type")
{
echoSearchResultsTableRows($search,"type",$index);
}
if($sortBy == "Keyword")
{
echoSearchResultsTableRows($search,"keyword1",$index);
echoSearchResultsTableRows($search,"keyword2",$index);
echoSearchResultsTableRows($search,"keyword3",$index);
echoSearchResultsTableRows($search,"keyword4",$index);
}
if($sortBy == "Author")
{
echoSearchResultsTableRows($search,"author1",$index);
echoSearchResultsTableRows($search,"author2",$index);
echoSearchResultsTableRows($search,"author3",$index);
}
if($sortBy == "all")
{
echoSearchResultsTableRows($search,"author1",$index);
echoSearchResultsTableRows($search,"author2",$index);
echoSearchResultsTableRows($search,"author3",$index);
echoSearchResultsTableRows($search,"keyword1",$index);
echoSearchResultsTableRows($search,"keyword2",$index);
echoSearchResultsTableRows($search,"keyword3",$index);
echoSearchResultsTableRows($search,"keyword4",$index);
echoSearchResultsTableRows($search,"month",$index);
echoSearchResultsTableRows($search,"year",$index);
echoSearchResultsTableRows($search,"date",$index);
}
echo "</table>";
echo "</div>";
}
mysql_close();
?>