Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <head>
- <title>product</title>
- <style type="text/css">
- span.row {
- display: table-row;
- }
- div.box {
- border:dashed 1px #eee;
- text-align:center;
- width:200px;
- height:50px;
- display: table-cell;
- padding:2px;
- }
- </style>
- </head>
- <body>
- <?php
- $id=isset($_GET['id'])?$_GET['id']:'';
- $db=new mysqli('localhost', 'my_user', 'my_password', 'my_db');
- if (mysqli_connect_error()) {
- die('Connect Error ('.mysqli_connect_errno().')'.mysqli_connect_error());
- }
- $qry="SELECT * FROM tbl_product".($id?" WHERE category_id='$id'":"");
- if($data=$db->query($qry)){
- $i=1;
- echo "<span class=\"row\">\n";
- while ($obj = $data->fetch_object()) {
- echo ($i%3==0?"</span>\n<span>\n":"")
- ."<div class=\"box\"><img src=\"".$obj->product_image."\" alt=\"".$obj->product_title."\">"
- ."<br>".$obj->product_price
- ."</div>\n";
- $i++;
- }
- echo "</span>\n";
- $data->close();
- }
- $db->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement