Jump to content

Recommended Posts

Hi

I am very new to php and have been asked to make some changes on my employers website. These changes are column names that appear in a table.  I have been able to successfully change the column names but the search function is not working.

The search function on our website has three boxes:  the first is for the field (column) you are searching and is a drop down box, the second is for the operator (ie. contains, starts with, equals etc.), the third is for the variable/term you are searching for.  When I search for a term that I know is the column, I get taken to a page that says 'no records found'. It is not an error message, and I believe the search is being performed but just no results are being found. I know that the database is being connected to and the search function works for other fields/columns.  I believe the code below has an error in it (probably a missing _ or ') but I have looked it over and compared it to to other code and I cannot find out what is missing.  Any help with this error is greatly appreciated.

 

Thank you so much!

 

// Action or Project 
$opt="";
$not=false;
$control_Action_or_Project=array();
$control_Action_or_Project["params"] = array();
if(@$_SESSION[$strTableName."_search"]==2)
{
$opt=@$_SESSION[$strTableName."_asearchopt"]["Action_or_Project"];
$not=@$_SESSION[$strTableName."_asearchnot"]["Action_or_Project"];
$control_Action_or_Project["params"]["value"]=@$_SESSION[$strTableName."_asearchfor"]["Action_or_Project"];
}
$control_Action_or_Project["func"]="xt_buildeditcontrol";
$control_Action_or_Project["params"]["field"]="Action_or_Project";
$control_Action_or_Project["params"]["mode"]="search";
$xt->assignbyref("Action_or_Project_editcontrol",$control_Action_or_Project);
$control1_Action_or_Project=$control_Action_or_Project;
$control1_Action_or_Project["params"]["second"]=true;
if(@$_SESSION[$strTableName."_search"]==2)
$control1_Action_or_Project["params"]["value"]=@$_SESSION[$strTableName."_asearchfor2"]["Action_or_Project"];
$xt->assignbyref("Action_or_Project_editcontrol1",$control1_Action_or_Project);

$xt->assign_section("Action_or_Project_fieldblock","<input type=\"Hidden\" name=\"asearchfield[]\" value=\"Action_or_Project\">","");
$notbox_Action_or_Project="name=\"not_Action_or_Project\"";
if($not)
$notbox_Action_or_Project=" checked";
$xt->assign("Action_or_Project_notbox",$notbox_Action_or_Project);

//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contains"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equals"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Starts with ..."."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."More than ..."."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Less than ..."."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Equal or more than ..."."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Equal or less than ..."."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Between"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Empty"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_Action_or_Project\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$xt->assign("searchtype_Action_or_Project",$searchtype);
//	edit format
$editformats["Action_or_Project"]="Text field";

Thanks gristoi but I changed the column name to "'Action or Project'" from "Recommendation".  I changed it in MySQL and all the other functions on the site work (ie. export, add field, edit etc.) just the search function won't work.  The search function works for all other columns/fields in this table though, so I am assuming (possibly incorrectly) that it has to do with the php code, though I guess it could be somewhere in the html.  I have gone through all the code (both html and php) and changed the old name "Recommendation" to "Action or Project" .  I don't get a php or html error message; but the search isn't performing properly because I don't get any results when I should. I think that the code above should capture the php where the error lies, but it is possible that the error is in another bit of code.  The thing this, the Search Query is written out in one file for use in all searches, so if the search works for the other searches I don't think it would be a problem with the Query, just with the code specific to this "Action or Project" column. 

I hope that makes some sense.  Unfortunately I am very new to php/html and code in general so I don't know if i am correct and hope that someone can look over this code to see if it is has mistakes.

 

Thanks!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.