Answer the question
In order to leave comments, you need to log in
How to select data from another table?
Hello! There is this code
<?php
$query = mysql_query("SELECT * FROM products", $connect);
if (!$query) {
echo "<div class='container'><p>Выборка данных из БД не произошла. Обратитесь к администратору.<p></div>";
exit(mysql_error());
}
if (mysql_num_rows($query) > 0) {
$result = mysql_fetch_array($query);
do {
printf("<tr><td>%s</td><td>%s</td><td><a href='edit_product.php?product_id=%s'>%s</a></td><td>%s</td></tr>", $result['product_id'], $result['product_cat'], $result['product_id'], $result['product_name'], $result['product_price']);
} while ($result = mysql_fetch_array($query));
} else {
echo "<div class='container'><div class='alert alert-danger' role='alert'>Новости отсутствуют.</div></div>";
//exit(mysql_error());
}
?>
Answer the question
In order to leave comments, you need to log in
$query = "SELECT `a`.*, `b`.* FROM `products` `a` LEFT JOIN `product_categories` `b` on `b`.`id`=`a`.`product_cat`";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question