mysql - Creat individual .php?id= links for each of the products in products.php file -
on products page, there several different product grids(created bootstrap) in which, of products displayed. trying create detailed pages each of products page has. products.php:
<?php session_start(); include('inc/config.php'); ?> <html> <body> content <div class="row"> <?php $query=mysql_query("select*from cars"); while($data=mysql_fetch_assoc($query)){ ?> <div class="col-md-4"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="text-center"> <?php echo "<h2>".$data['make']." ".$data['model']." </h2>"; ?></h4> </div> <div class="panel-body text-center"> <p class="lead"> <?php echo '<img src="cartest/'.$data['image'].'" class="img-responsive" />'; ?></p> </div> <ul class="list-group list-group-flush text-center"> <li class="list-group-item"><i class="icon-ok text-danger"></i><?php echo "<h4>".$data['price']." </h4>"; ?></li> <li class="list-group-item"><i class="icon-ok text-danger"></i>unlimited projects</li> <li class="list-group-item"><i class="icon-ok text-danger"></i>27/7 support</li> </ul> <div class="panel-footer"> <?php echo '<a class="btn btn-lg btn-block btn-default" href="product-details.php?id='.$data['carid'].'">details</a>';?> </div> </div> </div> <? } ?> </div> </body> </html>
product-details.php:
<?php session_start(); include('inc/config.php'); ?> <html> <body> content <div class="container-fluid"> <?php $id = $_get['carid']; $query = mysql_query("select * cars carid='$id'") or die(mysql_error()); $data = mysql_fetch_array($query); ?> <div> <?php echo '<img alt="" src="cartest/'.$data['image'].'"></a>'; ?> </div>
as can see, managed create individual links each of products there way of displaying individual pages using main template gonna change content section according product has been clicked? or have create countless pages each of products? in advance
if want change in template, need prefer it. for.eg. unique background can use this:
<div id="product" style="background: url($mybgurl)"></div>
in case $mybgurl
it's url product's image, fetched db.
p.s: google mvc or template engine.
Comments
Post a Comment