0

ok i think that i am missing something here but i not sure what.

i have a function with a class that is supposed to take all the data make a query and then put into an array the data i would like to collect later

function

function getDataLoop($strDbType, $table, $fields, $condition){
			if(!$this->dbConn($strDbType)) return false;
			
			$result = mysql_query("SELECT * FROM $table $condition");
	
        		while($myrow = mysql_fetch_assoc($result))
             		{
				 		foreach ($fields as &$value) {
							$loop[$value] .= $myrow[$value];
				 		}
				 
			 		}
					return $loop;
			if ($result) {
				$message = 'Yay the query was successfully run555.';
			}else{
			$message  = 'Invalid query: ' . mysql_error() . "\n";
    		$message .= 'Whole query: <em>' . $query . '</em>';
    		die($message);
			}
	}

within my page that i am calling it

$loop = $database->getDataLoop($strDbType, "pages", array("page_name", "id"), "");
		 foreach ($loop as $key => &$value)  
		 {
			 echo '<strong>'.$value."</strong><br />";  
		 }

now it puts it into an array but i dont think that the array is correct. when i echo out the loop values it does it like this
HomeProductsBlogHelpContact
12345

instead of like this
Home
Products
Blog
Help
Contact
1
2
3
4
5

im not sure where im going wrong.

thanks in advance

Edited by itisnot_me: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by itisnot_me
0

i found out what was the problem. im not sure the exact reason but i took out the key in the $loop[] from the function and then it started to work.

and actually it was supposed to echo out like this

Home
1
Products
2
Blog
3
Help
4
Contact
5

still dont get why. but it works so im fine.

Edited by itisnot_me: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.