php - Query database on clicking a link -
i'm retrieving products database , listing them in while loop. this
<?php while($row = mysql_fetch_row($result)){ echo '<div class="product_info">'; echo '<div class="category_product_title"><a href="category-page.php">product</a>'; echo '</div>'; echo '<div class="category_product_number">#'.$row[0].'('.$row[1].')'.'</div>';//prints id , name echo '<div class="category_product_description">'.$row[2].'</div>';//prints description echo '<div class="category_product_price">'.$row[4].'tl</div>';//prints price echo '<div class="category_details"><a href="productpage2.php">details</a></div>';//the link list product details echo '</div>'; echo '</div>'; } ?> i want able print more details on paticular prodcut when "details" link clicked getting id or name of paticular product , using query database. tried saving id in session variable $_session['id'] = $row[0] since i'm looping through these products, i'm not able id of specific product when clicked. how can this?. i'm confused because of loop. thanks
you can assign different link each 1 of products get variable.
instead of <a href="productpage2.php">details</a>, link point <a href="productpage2.php?id='.$row[0].'">details</a>.
then, on product page productpage2.php, can selected id $_get superglobal array this:
$id = $_get['id'];
Comments
Post a Comment