1

I have used the following code to search matching record from MYSQL database using HTML, PHP codes below all form element or textboxes works fine except this one. Its is very unusual for me i have spent a lot of time to identify what caused it but i cant see anything.

//inside HTML Form

  <tr>
    <td> 
     <label id="lbl_auto_year" for="auto_year" class="" >Search By Tread pattern:<br/>
     <input type="text" value="<?php echo htmlspecialchars($_REQUEST['pattern']); ?>" class="form-control input-sm" autocomplete="off" name="pattern" id="pattern" style="width:200px;color:#000;background:#fff" >
   </td>
 </tr>

//Requested as

  $txtpattern = $_REQUEST['pattern'];    

//if staement

  elseif (($row['Tread_Design']==$txtpattern || preg_match("/\b".preg_quote($txtpattern )."\b/i", $row['Tread_Design']) && ($size1=="" && $txtsize==""))
{
   echo "<td style=' width:300px;text-align:left; padding-left: 10px;vertical-align: middle;'>";echo $row['Manufacturer'];echo"</td>";
    echo "<td style=' width:150px;  text-align:left; padding: 10px;vertical-align: middle;'>";echo $row['Brand_Name'];echo"</td>";


 }

It doesn't give me any error but it doesnt display any result i know there are matching records in the database.

The funny part is when i change textbox name from name="pattern" to name="txtsize"(which already exist in the same form and working fine) i get the right result. I am not sure how that happens

Thamilhan
  • 13,040
  • 5
  • 37
  • 59
user5225773
  • 125
  • 1
  • 9
  • 1) Move the HTML code outside PHP using the PHP templating tags – oxygen Dec 29 '15 at 10:55
  • 2) Enable better PHP debugging: http://stackoverflow.com/a/11936959/584490 – oxygen Dec 29 '15 at 10:56
  • 3) Do proper debugging. Make the code easier on the eyes, inspect all variables values (breakpoints: throw new Exception(json_encode($someVariable)) at various execution points) and see if they have the expected values. – oxygen Dec 29 '15 at 10:56

0 Answers0