troubleshooting Question

Help looping results after initial call

Avatar of echocpt
echocptFlag for United Kingdom of Great Britain and Northern Ireland asked on
2 Comments1 Solution201 ViewsLast Modified:

I feel i am missing something blindingly obvious but i just can't get the code below to work. What i am trying to do is pull the results of a query and display them on a page. However if there are any options for the product being displayed they should be added into the select menu. I have got it working so that the select menu displays the last 3 options of a possible 4, but no mater what i do I can't get it to display the first result.

I believe it could be down to me calling on the query twice?

include ('./includes/');

$row = mysqli_fetch_array($r, MYSQLI_ASSOC);

<div id="content-wrapper">
	<div id="content-container" class="full-radius">
		<ul class="product-navigation">
			<li><a href="#" class="left-radius-6px left">Notebooks</a></li>
			<li><a href="#">Exercise Books</a></li>
			<li><a href="#">Sketchbooks</a></li>
			<li><a href="#">Diaries &amp Journals</a></li>
			<li><a href="#" class="right-radius-6px">Sale Items</a></li>
		<div id="header-text">
			<h1 class="header-text-detail"><?php echo $row['product_title']; ?></h1>
		<div id="detail-wraper">
			<div id="left">
				<div class="image-container"><img src="images/test_product_detail.png" alt="EcoBook" /></div>
				<div class="mini-image-container"></div>
				<div class="mini-image-container"></div>
				<div class="mini-image-container"></div>
			<div id="right">
				<h1>The Information</h1>
				<p><?php echo $row['product_long_description']; ?></p>
				<h1>The Quick Specs</h1>
				<p><?php echo $row['product_short_description']; ?></p>
				<span class="price"><?php echo get_price($row['product_price'], $row['sale_price']); ?></span>
				<form name="" action="/cart.php" method="post">
					<input type="hidden" name="pid" value="<?php echo $row['product_id']; ?>" />
					if(!is_null($row['colour_id'])) {
					$colour_list = "";
					while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
        				$colour_id = $row['colour_id'];
						$colour_title = $row['colour_title'];
						$colour_list .= "<option value=\"$colour_id\">$colour_title</option>\n";
					echo "<select name=\"colid\"/>$colour_list</select>";
					} else {
						echo '<input type="hidden" name="coid" value="NULL" />';
					<input type="hidden" name="action" value="add" />
					<input type="submit" value="Add to Bag" />
					<div class="buttons">
						<a href="#" class="button full-radius">
							<span class="bag">Add to Bag</span>
						<a href="#" class="button full-radius">
							<span class="">Add to Wishlist</span>

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros