sdrc Posted July 27, 2011 Share Posted July 27, 2011 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"; Quote Link to comment https://forums.phpfreaks.com/topic/242981-php-search-of-my-sql-database-no-records-found/ Share on other sites More sharing options...
gristoi Posted July 27, 2011 Share Posted July 27, 2011 errr, could it be because you changed the column name, did you change the sql search to match Quote Link to comment https://forums.phpfreaks.com/topic/242981-php-search-of-my-sql-database-no-records-found/#findComment-1248027 Share on other sites More sharing options...
sdrc Posted July 27, 2011 Author Share Posted July 27, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/242981-php-search-of-my-sql-database-no-records-found/#findComment-1248033 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.