S
S
shumilovdanil2016-02-19 10:46:33
PHP
shumilovdanil, 2016-02-19 10:46:33

Why are products from this category not displayed?

There is a function that organizes the selection of all products for a certain category in the db_dns.php file

function get_cut_products($cut)
   {
        db_connect();        
        $query = ("SELECT * FROM materinskieplati WHERE cut='$cut'") or die(mysql_error());                
        $result = mysql_query($query);       
        $result = db_result_to_array($result);                
        return $result;         
   }

And there is a page where this function should be implemented in the cut.php file
<?
  
  $cut = $_GET['id'];
  $productss = get_cut_products($cut);
  
  foreach($productss as $itemm):?>
  <html>
 <table align="center" cellpadding = "0" class="tovari" border="0" id="main-table"></table>
  <tr>
    <td align="top">
      <div> <a href="index.php?view=product_bp&id=<?echo $itemm['id']?>"><IMG src="images/<? echo $itemm['image']?> " width="100" height="111" alt="" /></a></div>
        <div class="discription">
                <div class="tovari-model"><a href="#"><? echo $itemm['Model']?></a></div>
        <div class="tovari-price">Price: <? echo $itemm['price']?></div>
      </div>
    </td>
  </tr>
    </td>
 </tr>
</table>
  </html>
  
  <?endforeach;?>

The problem is that when you click on a category, it simply does not display anything, an empty window and that's it. What to do? Tell me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mletov, 2016-02-19
@shumilovdanil

Do
it and see if anything came into the selection

A
Alexander Sharihin, 2016-02-19
@Pinsky

Use some wrappers to work with the database.
It's possible that what you're passing to $cut isn't in the table - so there's nothing in the output.
Check the spelling of the table name, field, and parameter.
Try rewriting the query to something like this:

$select_query = mysqli_prepare($db_link, "SELECT * FROM materinskieplati WHERE cut=?");
mysqli_stmt_bind_param($select_query, 'i', $cut);
$select_query->execute();

Well, and so on.
Well, or use some kind of ORM.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question