1
I’m having a problem, no matter how hard I try, I can’t fix it.. The problem is in:
<form action="" method="POST">
<div class="containercompras">
<div class="box">
<div class="imgBox">
<img class="imagem" src="images/imgbox1.jpg">
</div>
<div class="descricao">
<div class="contentdescr">
<h2>Sombras</h2>
<p><a href="aaa.php" name="versombras">Ver mais</a></p>
</div>
</div>
</div>
<div class="box">
<div class="imgBox">
<img class="imagem" src="images/imgbox2.jpg">
</div>
<div class="descricao">
<div class="contentdescr">
<h2>Rimel</h2>
<p><a href="">Ver mais</a></p>
</div>
</div>
</div>
The part where I have to see more I’m supposed to load and go to another page and show certain products, which I’ll get from the database. They on the other page works perfectly, I just can’t do that by pressing "See more" go to the other page and show only those products of a single category..
On the other page I did so for all categories and gave:
<?php
header('Content-Type: text/html;charset=UTF-8');
include("ligabd.php");
if (isset($_POST['sombras'])) {
$procura = "SELECT * FROM produtos WHERE id_categoria='1'";
...
?>
Thanks for the help!! But in the code part --> $search = "SELECT * FROM products WHERE id_categoria='$id' "; (Pag. aaa.php) how does he get the category 1 products, where it is "id_categoria='$id' "? From what you said, would you have to add this line of code, or change the one I mentioned in the question? (pág aaa.php)
– Ana
So Ana, did you see that the link is aaa.php? id=1 ?? Did you see that you have after php (?) a parameter? In php you can pass values through the link, and inside the page you can call the value of this parameter, so it’s WHERE id_category ='$id' ", because the $id is worth 1(pq on the link is aaa.php?id=1 <-) and php is reading this, you see id_categoria = '$id', but PHP knows that the $id is worth 1, so it sees id_categoria = 1, got it?
– brnTwp
Do a test, on the aaa.php page, type just below the $id = (int) $_GET['id']; this one: echo $id; Go to the two "see more" buttons and you will see that it shows on the screen, the number 1 in "Shadows" and the number 2 in "Rimel"
– brnTwp
Yes I tested and gave, but only if you delete the rest of the code " if (isset($_POST['shadows'])) { $search = "SELECT * FROM products WHERE id_categoria='1'"; }elseif (isset($_POST['rimel'])) { $search = "SELECT * FROM products WHERE id_categoria='2'"; ------ And I need this code for when to go to page appear all products, but however as you said it worked, my question now is, how I integrate that into my code so that I don’t erase what I’ve been doing?
– Ana
I at this point simply put the part of the code you suggested over the "if(isset($_POST['shadows'])) { $search= ... }
– Ana
Yes yes, but it was intentional to remove this part, because in my understanding you used it to see if when you selected the "see more" of the "shadows" you searched by id_categoria=1, and consequently by 2. This search will only search equivalent to the item you clicked on index.php. I don’t know if I made myself clear, but you don’t have to use the isset anymore.
– brnTwp
Do so, tell me what is the ID equivalent to the item Shadows in your database.
– brnTwp
The ID of the item shadows in my database is 1 You’ve helped me a lot so far, I’m not being able to integrate into the code! But if I don’t have isset by pressing the button no product appears ...
– Ana
Let’s do it this way, post all your code from aaa.php, just so I can analyze all your syntax.. I think there must be a "}" lost.. Hence the syntax error and total PHP failure.. So you don’t list anything.. Update your question with all of aaa.php to set it up.
– brnTwp
I already posted, if you can help me, I’d really appreciate it, this is my final exam! I posted as an answer to my own question, I forgot to update the question...
– Ana