HELP.. PHP

C++, C#, Java, PHP, ect...
Post Reply
aduss
Posts: 12
Joined: Sat Mar 17, 2012 6:02 pm

HELP.. PHP

Post by aduss »

Hello, I am working on site for friend who don't know anything about programming, so there is administration section.. The point of site is that he can add the new product(it is not an eshop) which will be shown in the index, but I can't move on because I have no idea what to do when someone click on that product it should display name and 1 image which can be clicked to 2nd and so on /all can have different number of images/.. I hope you understand.. I don't know how to explain it in my language, not even in foreign.. :D please help.. I am really desperate :cry: THANKS ;)
User avatar
Flap_Jack
Posts: 12
Joined: Mon Oct 08, 2012 11:30 am

Re: HELP.. PHP

Post by Flap_Jack »

I think i know what you mean, and how to solve this...
But how have you made all the other pages?
Are the "products" saved in a database, and then you made a while to get out all the information from the databse?
If you made it like that, it's quite easy to make, you just need to create a page more, and add some code to the other, just like this:


Code on the page you've already made:

Code: Select all

<?php 
$query = mysql_query("SELECT * FROM the-table-name-here ORDER BY id DESC LIMIT 10");
while($row = mysql_fetch_assoc($query)) {
//Here you put in the code to show the title, picture and so. And then also insert this:
?><a href="product.php?id=<?php echo $row['id']; ?>">//Whatever the links title needs to be.</a>
}

?>
Then the product.php page:

Code: Select all

<?php
$id = $_GET["id"];
$query = mysql_query("SELECT * FROM the-table-name-here WHERE id='$id' ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_assoc($query);
//Now we got information enough to make the other parts as picture, text and more. Just do something like this:
?>
<h2><?php echo $row['title-row-name-here']; ?></h2><br>
<p><?php echo $row['text-row-name-here']; ?></p>
//And so on ;)
This is just a simple version made with the $_GET function.
I hope this helped you, and you understand me.
Post Reply

Return to “Coding”