Hello, I’m a noob and I’m writing the first search, generally made a check in and out of the database. Help to make each field displayed separately.

$search = $_POST['search']; $id_s = $_POST['id']; $group_s = $_POST['group']; $number_s = $_POST['number']; $famely_s = $_POST['famely']; $result = mysql_query("SELECT * FROM file WHERE id = '$id_s' OR famely = '$famely_s'"); if ($search) { if($group_s == "" OR $number_s == "" OR $famely_s == "") { $result = mysql_query("SELECT * FROM file WHERE id = '$id_s'"); } elseif ($number_s == "" OR $famely_s == "") { $result = mysql_query("SELECT * FROM file WHERE id = '$id_s' group = '$group_s'"); } elseif ($famely_s == "") { $result = mysql_query("SELECT * FROM file WHERE id = '$id_s' nomber = '$number_s' group = '$group_s'"); } elseif($id_s == "" OR $number_s == "" OR $famely_s == "") { $result = mysql_query("SELECT * FROM file WHERE group = '$group_s'"); } elseif ($id_s == "" OR $group_s == "" OR $number_s == "") { $result = mysql_query("SELECT * FROM file WHERE famely = '$famely_s'"); } } else { $result = mysql_query("SELECT * FROM file ") or die ( mysql_error() ); } 
  • one
    WHERE id = '$id_s' group = '$group_s' Such constructions should be separated by the keywords OR or AND - etki
  • Ammm, they work))) I will correct later, but elseif ($ id_s == "" OR $ number_s == "" OR $ famely_s == "") {$ result = mysql_query ("SELECT * FROM file WHERE group = ' $ group_s' "); Doesn't plow - bajex
  • one
    group - reserved word in SQL, it must be taken in the reverse apostrophes (on the same key as the tilde) - etki
  • Right now I didn’t understand anything o_O - bajex
  • Also elseif ($ id_s == "" OR $ group_s == "" OR $ number_s == "") {$ result = mysql_query ("SELECT * FROM file WHERE famely = '$ famely_s'") does not work either; } - bajex

0