please i need to query 2 tables at once and display the content in table. here is the code:

<?php
                   include 'database.php';
                   $pdo = Database::connect();
                   $sql = 'SELECT producs.*,validation_superviseur.* FROM products ORDER BY product_id DESC ,validation_superviseur ORDER BY id DESC';
                   foreach ($pdo->query($sql) as $row) {
                            echo '<tr>';
                            echo '<td>'. $row['cat_id'] . '</td>';//this is retrieved from TABLE products

                            echo '<td><a href="details.php?brand_id='. $row['brand_id']. '">'. $row['brand_id']. '</a></td>';// this is retrieved from TABLE products

                            echo '<td>'. $row['product_title'] . '</td>';//this is retrieved from TABLE products
                            echo '<td>'. $row['product_img1'] . '</td>';//    this is retrieved from TABLE products

                            echo '<td>'. $row['reaction'] . '</td>';  //  this is retrieved from TABLE validation_superviseur                 
                            echo '</tr>';
                   }
                   Database::disconnect();
                  ?> 

Recommended Answers

All 3 Replies

And what problem are you having?
Is it the typo in 'select producs.' in your SQL statement? Or something else?
Seeing as your only using a few of the selected columns you can change your query from selecting all to just the ones you need. ut that won't fix the undescribed problem you're having, it's just a tip - Selecting all every time is just lazy ;)

found it
ERROR:

SELECT producs.*

You are extracting from two tables without a join condition???
why?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.