bullbreed Posted March 15, 2010 Share Posted March 15, 2010 HI Guys I have some serialised data in my database related to the colour of a product. The data is actually a link to an image of a coloured square 22px x 22px representing a colour. In order to unserialise it and I used the following code; <?php $sql = "SELECT * FROM `products` WHERE `prod_name` = '".$_GET['nid']."' limit 1 "; $query = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($query) > 0) { while ($row = mysql_fetch_assoc($query)){ $colours = $row['prod_colours']; $colours = stripslashes($colours); $colours = unserialize($colours); $itemcount = count($colours); for ($i=0;$i<$itemcount;$i++) { ?> <div class="colours"><a href="productdesign.php?nid=<?php echo $row['prod_name']; ?>&colid="<?php echo $row['prod_colours']; ?> > <?php echo '<img src="' .$colours[$i]. '">'; ?></a></div> <?php } } } ?> But when the colour is selected I need a nedw image to appear on screen which will be the product in the required colour. How do I add a value to the coloured square so when it is clicked I can call it as 'colid', meaning the page will be; prodtype.php?nid=value&colid=value associated with square image I hope I have explained ok. Link to comment https://forums.phpfreaks.com/topic/195336-adding-values-to-variables/ Share on other sites More sharing options...
wildteen88 Posted March 15, 2010 Share Posted March 15, 2010 The following code is correct for your link. <div class="colours"><a href="productdesign.php?nid=<?php echo $row['prod_name']; ?>&colid="<?php echo $row['prod_colours']; ?> > However the quote before this bit here <?php echo $row['prod_colours']; ? should be after it, eg <div class="colours"><a href="productdesign.php?nid=<?php echo $row['prod_name']; ?>&colid=<?php echo $row['prod_colours']; ?>" > Link to comment https://forums.phpfreaks.com/topic/195336-adding-values-to-variables/#findComment-1026551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.