Jump to content

Search the Community

Showing results for tags 'foreign-keys'.

  • 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. I have the following tables: USERS -id -fname -lname COMPANIES -id -name -type PRODUCTS -id -product -restaurant (linked to companies.id) -vendor (linked to companies.id) -user (linked to users.id) -transaction_date I have the following code to try to output data from the Products table but it isn't working: $sql = mysql_query("SELECT products.*, companies.name FROM products INNER JOIN companies ON products.vendor = companies.id ON products.restaurant = companies.id WHERE vendor='$id' AND companies.type='$type'") or die(mysql_error()); $num=mysql_num_rows($sql); <th><h5>Date</h5></th> <th><h5>Meal</h5></th> <th><h5>Restaurant</h5></th> <th><h5>Vendor</h5></th> $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"transaction_date"); $f2=mysql_result($result,$i,"product"); $f3=mysql_result($result,$i,"restaurant"); $f4=mysql_result($result,$i,"vendor"); <td><?php echo $f1; ?></td> <td><?php echo $f2; ?></td> <td><?php echo $f3; ?></td> <td><?php echo $f4; ?></td> $i++; } I looked on another site and found this answer: http://stackoverflow...-keys-php-mysql but that doesn't help. The problem is that I can only get either the restaurant or vendor name to show but not both. The $id and $type are created with the session, fyi. Any ideas? Thank you
×
×
  • 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.