Jump to content

Search the Community

Showing results for tags 'foreignkey'.

  • 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 written by someone else which works fine for running searches on multiple columns. I have just included in it a category field, which is a foreign key from the categories table, and I want to run queries with this one also, but currently am not getting results when I run queries with the category (foreign key). the code: <?php if ($_REQUEST["string"]<>'') { $search_string = " AND (ctitle LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%' OR csubject LIKE '%".mysql_real_escape_string($_REQUEST["string"])."%')"; } if ($_REQUEST["ref"]<>'') { $search_string = " AND (creference LIKE '%".mysql_real_escape_string($_REQUEST["ref"])."%')"; } if ($_REQUEST["category"]<>'') { $search_category = " AND category='".mysql_real_escape_string($_REQUEST["category"])."'"; } if ($_REQUEST["cmaterial"]<>'') { $search_cmaterial = " AND (cmaterial LIKE '%".mysql_real_escape_string($_REQUEST["cmaterial"])."%')"; } if ($_REQUEST["ctechnic"]<>'') { $search_ctechnic = " AND (ctechnic LIKE '%".mysql_real_escape_string($_REQUEST["ctechnic"])."%')"; } if ($_REQUEST["cartist"]<>'') { $search_cartist = " AND (cartist LIKE '%".mysql_real_escape_string($_REQUEST["cartist"])."%')"; } if ($_REQUEST["cperiod"]<>'') { $search_string = " AND (cperiod LIKE '%".mysql_real_escape_string($_REQUEST["cperiod"])."%')"; } if ($_REQUEST["csource"]<>'') { $search_string = " AND (csource LIKE '%".mysql_real_escape_string($_REQUEST["csource"])."%')"; } if ($_REQUEST["cyear"]<>'') { $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE cyear = '".mysql_real_escape_string($_REQUEST["cyear"])."'".$search_string.$search_category; } else { $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE c_id>0".$search_string.$search_category.$search_cmaterial.$search_ctechnic.$search_cartist; } $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); if (mysql_num_rows($sql_result)>0) { // The following line gives us an SQL statement with appropriate limits applied $sql_result=mysql_query($sql) or die($sql." - ".mysql_error()); while ($row = mysql_fetch_assoc($sql_result)) { // and the result table goes below ... ?> This is the select drop down list for categories: <select name="category"> <option value="">--Object Category--</option> <?php $sql = "SELECT cat_id,category FROM categories GROUP BY category ORDER BY category"; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); while ($row = mysql_fetch_assoc($sql_result)) { echo "<option value='".$row["category"]."'".($row["category"]==$_REQUEST["category"] ? " selected" : "").">".$row["category"]."</option>"; } ?> </select> Is it because I am escaping it (foreign key) like a string or something else? 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.