Jump to content

mysqli_fetch_row() problem ... help!


Jaguar83

Recommended Posts

Hi all, thanks for taking the time to look at my problem...Forgive me if this is not in the right forum (I will post in the more general PHP forum if any of you feel that it is a better location for the question).

 

I have a simple MySQL database with a 'coinorder' table. The table is populated correctly, etc. When I run the query within MySQL (copy and paste the result of '$query_vieworders'...which is the correct query), it executes and returns the data properly. When I implement it within my code, it only, seemingly, prints out every other row in html and the '$temp_orderview[0]' below is not correct.

 

<?php
$addorder_list = array('order_id',
					'account_id',
					'order_rcvd_month',
					'order_rcvd_day',
					'order_rcvd_year',
					'order_shipmeth',
					'order_comm',
					'user_id');

$query_vieworders = 'SELECT ';
foreach($addorder_list as $sqlname) {
	if ($sqlname == 'order_id') {	
		$query_vieworders .= 'order_id';
	}
	else {	
		$query_vieworders .= ', ' . $sqlname;
	}
}
$query_vieworders .= ' FROM coinorder ';
if(empty($_GET['order'])) {
	$query_vieworders .= 'ORDER BY order_id';
}

//	echo $query_vieworders;

$result_vieworders = mysqli_query($dbc, $query_vieworders)
	or die(mysqli_error($dbc));

echo '<div id="vieworder">
		<h3>Select Order</h3>
		<table id="vieworder">
			<tr class="tablehead">';
			foreach($addorder_list as $name) {
				echo '<td>' . $name . '</td>';
			}
		echo '<td></td>
			</tr>';
		while ($temp_orderview = mysqli_fetch_row($result_vieworders)) {
			echo '<tr>';
			foreach ($temp_orderview as $temp_val) {
				echo '<td>' . $temp_val . '</td>';
			}
			echo '<td><a href="order.php?req=addcoinpack&id=' . $temp_orderview[0] .'>Add Coin(s)</a></td>
			</tr>';
		}
		echo '</table>
		</div>';
?>

 

Can anyone spot my problem? I apologize if the formatting is a little off, I'm new to Eclipse. Thanks and happy PHPing!

Link to comment
Share on other sites

And to clarify, there are no syntax issues in this code (that I can detect). The script runs fine and does not produce errors, it just does not work in the fashion for which it was designed.

 

I apologize for not mentioning this: Eclipse is a popular open-source IDE.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.