Jump to content

[SOLVED] Simple problem - solution eluding me...


amites

Recommended Posts

Well I'm working on my first serious PHP mySQL project in a while and running into a road block

 

			$sql = "SELECT * FROM venue_seating WHERE venue_id = '" .$venue['venue_id']. "' AND section = '" .$venue_row['section']. "' ORDER BY row ASC";
		$res = mysql_query($sql) or die(mysql_error());
	var_dump($res);
		while ($rec = mysql_fetch_assoc($res)) {

 

the var_dump says there are 11 resources recovered from the query, but when I try to print them out after the while statement it leaves me blank...

 

what am I missing, I know it's obvious, thinking 13 hours might be my limit for the day...

Link to comment
Share on other sites

I added the var_dump after it wasn't providing any results,

 

I've gone through and checked before and after the while statement, and the only thing that stays true is that before the while statement there are results in the array and none after it,

 

I based the query on results from a previous query not sure what's off, only that it's something obvious,

 

for a little more detail I'm throwing in more of the surrounding code...

 

			$sql = "SELECT * FROM venue_seating WHERE venue_id = '" .$venue['venue_id']. "' AND section = '" .$venue_row['section']. "' ORDER BY row ASC";
		$res = mysql_query($sql) or die(mysql_error());
//		var_dump($res);
		while ($rec = mysql_fetch_assoc($res)) {
//		print $rec;
			$venue_seat[] = $rec;

		print_r ($venue_seat);
//			var_dump ($rec);
//			var_dump ($venue_seat);

 

everything after the while statement comes up blank, before it has 11 resources available...

 

I appreciate the help with something I know is simple

Link to comment
Share on other sites

Again, forget about dumping $res and after the while loop because the data has already been read (within the while loop) so there's nothing to dump per say. Each of your post never show the complete code in the while loop or at least you don't show where the ending right curly brace is ("}").

 

Do you really have a column simply called "row"?

 

What are you trying to do exactly? Are you trying to save off all the row results? because that's what it looks like you're doing with: $venue_seat[] = $rec;

 

<?php
// Open and select DB up here

$sql = "SELECT * FROM `venue_seating` WHERE `venue_id` = '" .$venue['venue_id']. "' AND `section` = '" .$venue_row['section']. "' ORDER BY `row` ASC";
$res = mysql_query($sql) or die(mysql_error());

$venue_seat = array();
while ($rec = mysql_fetch_assoc($res)) {

    print_r($rec);  // Would print one row of data - each column is an associated array index with it's value

    $venue_seat[] = $rec; // This saves the array $rec into another array called $venue_seat to save every row


} // end of while loop

print_r($venue_seat);  // would print an array of associated row arrays


?>

 

Look at manual page for other code example:

http://us2.php.net/manual/en/function.mysql-query.php

 

 

Link to comment
Share on other sites

thank you toplay,

 

I had to run around in a circle for a few minutes putting a nice long thought out question together and came to my own answer,

 

$venue_row[] was being set by a previous query and resulted in a nested array which I didn't see until I var_dumped each variable at each step,

 

now time to refresh myself on pulling value from a nested array and I'm on to the next part of this project, tracking tickets to events in these places...

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.