Member Avatar for itisnot_me

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

Member Avatar for itisnot_me

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.