I want my site to search for any product that belonged to particular size when click any size option in the table cell for desktop users but I am having two challenges
My loop for horizontal cells suppose to be incrementing from left to right like this 28D, 28DD, 28E, 28F, 28FF, 28G ...28K and then move to second line 30D --- 30k but instead it was reapeating each value 12 times horizontally like this 28D, 28D, 28D 12times and move to second line 28DD repeating it 12 times again. Please what could be the problem in my four loop?
I don't know how to put anchor tag around the table cell and how to put name = size attribute in the table cell for it to link sizeresult.php. where it will be processed by the select query here is my code:
<div class="table-responsive"><!-- table-responsive begin --> <table class="table table-striped table-hover" border="0" width="100%" cellpadding="5" cellspacing="5"> <thead> <tr> <th class="success"> <h4 class="text-center white-text">D</h4> </th> <th class="info"> <h4 class="text-center white-text">DD</h4> </th> <th class="danger"> <h4 class="text-center white-text">E</h4> </th> <th class="success"> <h4 class="text-center white-text">F</h4> </th> <th class="info"> <h4 class="text-center white-text">FF</h4> </th> <th class="danger"> <h4 class="text-center white-text">G</h4> </th> <th class="success"> <h4 class="text-center white-text">GG</h4> </th> <th class="info"> <h4 class="text-center white-text">H</h4> </th> <th class="danger"> <h4 class="text-center white-text">HH</h4> </th> <th class="success"> <h4 class="text-center white-text">J</h4> </th> <th class="info"> <h4 class="text-center white-text">JJ</h4> </th> <th class="danger"> <h4 class="text-center white-text">K</h4> </th> </tr> </thead> <tbody> <?php $count = 12; // Number of possible cells to add at once: $i=0; $get_sizes = "select * from sizes"; $run_sizes = mysqli_query($dbc,$get_sizes); while ($row_sizes=mysqli_fetch_array($run_sizes)){ $size_id = $row_sizes['size_id']; $size_name = $row_sizes['size']; $i++; ?> <tr> <?php for ($i = 1; $i <= $count; $i++) { echo " <td value='$size_name' align='center'> $size_name </td>"; } // End of FOR loop. ?> </tr> <?php } ?> </tbody> </table> </div> <!-- table-responsive end --> </form>
sizeresult.php code is this :
$size_name=$_POST['size'];
$run_products = mysqli_query($dbc,"SELECT * FROM products INNER JOIN SIZES USING (size_id) WHERE sizes.size ='%$size_name%'");