Jump to content

Search the Community

Showing results for tags 'multiplesearch'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi, I found a script http://www.weberdev....?ExampleID=4406 by someone called "Suraj Thapaliya" for doing a multiple search using PHP and MySQL. I am trying to adopt it to my own use for one application am putting up together with the help of different scripts. In my application, if I populate only one of the text boxes or combo boxes the search is executed fine. But the problem is that when I use two or more criterias I am getting an error like the one below: ; in which case I used the cmaterial combo box and ctitle text box as the criteria. The following are combo boxes: cmaterial, cobjecttype and ctechnic, while the rest are text boxes. My code is as follows: <? include("includes/conn.php"); $ctitle=$_POST["ctitle"]; $csubject=$_POST["csubject"]; $creference=$_POST["creference"]; $cyear=$_POST["cyear"]; $cobjecttype=$_POST["cobjecttype"]; $cmaterial=$_POST["cmaterial"]; $ctechnic=$_POST["ctechnic"]; $cwidth=$_POST["cwidth"]; $cheight=$_POST["cheight"]; $cperiod=$_POST["cperiod"]; $cmarkings=$_POST["cmarkings"]; $o=$_POST["o"]; $rest=""; $text="Search Keywords : "; if($ctitle!="") { if($rest=="") { $rest.="where ctitle Like '$ctitle%' "; $text.="Item Title = $ctitle"; } else { $rest.=" $o ctitle = '$ctitle' "; $text.=", Item Title = $ctitle"; } } if($csubject!="") { if($rest=="") { $rest.="where csubject = '$csubject' "; $text.="Subject = $csubject "; } else { $rest.=" $o csubject = '$csubject' "; $text.=", Subject = $csubject "; } } if($creference!="") { if($rest=="") { $rest.="where creference = '$creference' "; $text.="Reference No. = $creference"; } else { $rest.=" $o creference = '$creference' "; $text.=", Reference No. = $creference"; } } if($cyear!="") { if($rest=="") { $rest.="where cyear Like '$cyear%' "; $text.="Year = $cyear"; } else { $rest.=" $o cyear = '$cyear' "; $text.=", Year = $cyear"; } } if($cobjecttype!="") { if($rest=="") { $rest.="where cobjecttype Like '$cobjecttype%' "; $text.="Object = $cobjecttype"; } else { $rest.=" $o cobjecttype = '$cobjecttype' "; $text.=", Object = $cobjecttype"; } } if($cmaterial!="") { if($rest=="") { $rest.="where cmaterial Like '$cmaterial%' "; $text.="Material = $cmaterial"; } else { $rest.=" $o cmaterial = '$cmaterial' "; $text.=", Material = $cmaterial"; } } if($ctechnic!="") { if($rest=="") { $rest.="where ctechnic Like '$ctechnic%' "; $text.="Technic = $ctechnic"; } else { $rest.=" $o ctechnic = '$ctechnic' "; $text.=", Technic = $ctechnic"; } } if($cwidth!="") { if($rest=="") { $rest.="where cwidth Like '$cwidth%' "; $text.="Width = $cwidth"; } else { $rest.=" $o cwidth = '$cwidth' "; $text.=", Width = $cwidth"; } } if($cheight!="") { if($rest=="") { $rest.="where cheight Like '$cheight%' "; $text.="Height = $cheight"; } else { $rest.=" $o cheight = '$cheight' "; $text.=", Height = $cheight"; } } if($cperiod!="") { if($rest=="") { $rest.="where cperiod Like '$cperiod%' "; $text.="Period = $cperiod"; } else { $rest.=" $o cperiod = '$cperiod' "; $text.=", Period = $cperiod"; } } if($cmarkings!="") { if($rest=="") { $rest.="where cmarkings Like '$cmarkings%' "; $text.="Markings = $cmarkings"; } else { $rest.=" $o cmarkings = '$cmarkings' "; $text.=", Markings = $cmarkings"; } } if($rest!="") { $rest=$rest; } else { //die("Enter Search Parameter<br><br><br><br><br><br><br><br><br><br><br>"); } //Number of items to display per page $perpage = 16; if(isset($_GET["page"])) { $page = intval($_GET["page"]); } else { $page = 1; } $calc = $perpage * $page; $start = $calc - $perpage; ////////////////// $sql="select * from $tbl_name $rest Limit $start, $perpage"; $result=mysql_query($sql) or die(mysql_error()); $num=mysql_num_rows($result); ?> Please, what did I do wrong? joseph
×
×
  • 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.