Dear community,
May I ask you for your help please.
I have two pages: item page, where customer selects required size and basket page, where this size is displayed alongside other information. All the data is passed OK, but 'size' data is not.
Here are the pieces of code that created a small headache for me for a few days:
item page:
<?php while($row=mysql_fetch_array($result)) { ?>
<div id="gallery">
<a href="Images/<?php echo $row['image_URL']; ?>" title="<?php echo $row['item_name']; ?>"><img src="Images/<?php echo $row['image_URL']; ?>" width="214" height="308" alt="<?php echo $row['item_name']; ?>" align="left" /></a>
<a href="Images/<?php echo $row['screen1_URL']; ?>" title="<?php echo $row['item_name']; ?>"><img src="Images/<?php echo $row['screen1_URL']; ?>" width="92" height="132" alt="<?php echo $row['item_name']; ?>" align="left" /></a>
<a href="Images/<?php echo $row['screen2_URL']; ?>" title="<?php echo $row['item_name']; ?>"><img src="Images/<?php echo $row['screen2_URL']; ?>" width="92" height="132" alt="<?php echo $row['item_name']; ?>" align="left" /></a>
</div>
<div class="item">
<p class="gallery-indivitem"><?php echo $row['item_name']; ?></p>
<p class="gallery-blacksmall"> <?php echo $row['item_price']; ?> рублей</p><br /><br />
<p class="gallery-blacksmall"><?php echo $row['long_description']; ?></p>
<p class="gallery-blacklarge">Выбрать размер
<select name="sel_size" id="sel_size">
<option value="one"><?php echo $row['size']; ?></option>
<option value="two"><?php echo $row['size1']; ?></option>
<option value="3"><?php echo $row['size2']; ?></option>
<option value="4"><?php echo $row['size3']; ?></option>
<option value="5"><?php echo $row['size4']; ?></option>
</select>
</p>
<a class="smallblue" href="#" >Помощь с размером</a><br />
<a class="smallblue" href="javascript: history.back();" >Вернуться</a><br /><br />
<a href="busket.php?action=add&id=<?php echo $row['item_id']; ?>"><button type="submit" class="button" name="submit1" value="submit"></button> </a>
<?php } ?>
basket page:
foreach ($contents as $id=>$qty) {
$sql = 'SELECT * FROM `ITEM` WHERE `item_id` = '.$id;
$cartresult=mysql_query($sql);
while($cartrow = mysql_fetch_array($cartresult)) {
$output[] = '<tr>';
$output[] = '<td>'.$cartrow['item_name'].'</td>';
$output[] = '<td>'.$cartrow['sel_size'].'</td>';
$output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="2" maxlength="2" /></td>';
$output[] = '<td><p class="small">'.($cartrow['item_price'] * $qty).'</p></td>';
$output[] = '<td><a class="smallblueagain" href="busket.php?action=delete&id='.$id.'">удалить</a></td>';
$total += $cartrow['item_price'] * $qty;
$_POST['total'] = $total;
$output[] = '</tr>';
The problem is that when I add any 'name' to the select box, it does not pass any size information to the basket page, however, if I change the 'name' of the select box to any 'name' from the available options such as size, size1, size2 etc, it only displays that particular data associated with that size.
I think the issue is with this two pieces of code (see below), however I am not sure how to change this and make the selected size be correctly displayed on the basket page.
<select name="sel_size" id="sel_size">
insert page
$output[] = '<td>'.$cartrow['sel_size'].'</td>';
busket page
Do I need to create a variable for the size or maybe my database table is constructed badly?
Thank you for any help,
Annushka