Having products from the database

Asked

Viewed 41 times

0

I need help because I need to have the products I have in my database on the products page.

Follow an image to show where I want to insert inserir a descrição da imagem aqui

  • What have you tried? Is this image just the image? Or html you’ve already made?

  • It’s just a picture. I didn’t try because I don’t know whether to put an array and then put it in the place of the images or if there’s a better way to do it and that’s what I need help with

  • I would suggest that you start by trying to make an HTML and CSS that looks like the final image, even before you do PHP (I assume), when you’re happy with the look, you start working on PHP to fetch the products and make the dynamic product list. Small steps.

  • but that is already my design already this all just missing php same

  • Yeah, I figured that’s the design you want to do.

  • the design is already done, only missing by php for the images and price

  • If you already have HTML and CSS, follow @I_like_trains' suggestion, that’s the way you need to go.

  • ae a good cart for the start http://www.davidchc.com.br/tutorials/php-tutorials/addir-opcoes-dos-products-shoppingcart-com-php/ take a look at it and start deploying if you like ;P

  • @Willian this is cart that is a totally different thing and will be to do further ahead, but thanks for the help

  • 1

    "the design is already done, only missing by php for the images and price" cara la tem a parte completa de vitrine/ carrinho um ta ligado ao outro!

Show 5 more comments

2 answers

1

You must do so

<?php
$db=mysqli_connect(bla, bla, bla, bla); //Campos da ligação
$query=mysqli_query($db, "SELECT * FROM tabela"); //Caso use mysqli
while($mostra=mysqli_fetch_assoc($query)){ //Caso use mysqli
?>
<img src="src da pasta da imagem/<?=$mostra['imagem']; ?>" />
<span><?=$mostra['nome']; ?></span>
<?php
}
?>

With this you have the essentials and you will have to do the css as you wish.

  • yes , but there is no way to be soon all items and not just one at a time?

  • But it will show all, not one at a time. It has to have a loop to see how many there are and which to show

0

I would suggest that you start by trying to make an HTML and CSS that looks like the final image, even before doing PHP (I assume), when you’re happy with the look, you start working on PHP to fetch the products and make the dynamic list. Small steps.

By doing HTML you are first defining your document structure, then making it easier to do PHP to make certain parts of that document dynamic, with data coming from the database.

I would suggest even if you tried this, and you were putting problems here that you’re finding, if you haven’t experienced something yet, probably the help we’re going to give you will confuse you further or it won’t be the best exercise to learn what to do next time.

One thing I did when I was learning was to copy HTML and CSS from other sites and understand why it was done the way it was.

  • A question with an image of the ultimate goal, asking how to list products, without any code to be shown, leads me to believe that nothing is yet done, just an image. If to move from an image to something that works are not, by definition, these steps, I do not know then what it is. If the negative vote is for not doing the work that someone else has to do, then something is very bad in this community.

  • You are absolutely right. Just show the image and ask everyone to do the rest can give reason for the closing of the question.

  • Yes. I would prefer the question to have more information than is done or not done, and at what stage if you’re having problems, so we can help, which I think we all like to do. Your answer does answer the question’s title, but the text of the question should have more information, even so you can adapt your answer to be more focused on his case.

  • 1

    I gave you +1 to repair the damage he did and I’ve flagged the question as not clear enough

  • I realized that was it, thank you :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.