Hello:
I have a question with the following code:
$sql_db_select = mysql_query("SELECT * FROM test");
if(mysql_num_rows($sql_db_select) > 0) {
while($row=mysql_fetch_array($sql_db_select)) {
foreach ($row as $key => $value) {
print "$key=$value<br>";
}
print_r($row);
}
}else{
print "no good";
}
returns:
0=2
id=2
1=test 1
title=test 1
2=teseer
teaser=teseer
3=asdfasdfsdfafasdsdfa
text=asdfasdfsdfafasdsdfa
4=2004-12-13
date=2004-12-13
Array ( [0] => 2 [id] => 2 [1] => test 1 [title] => test 1 [2] => teseer [teaser] => teseer [3] => asdfasdfsdfafasdsdfa [text] => asdfasdfsdfafasdsdfa [4] => 2004-12-13 [date] => 2004-12-13 )
As you can see the array contains the values twice, once with the number [3] and once with the databases field name. So how do I do a foreach that will ignore the one with the number [3] and only do the ones with the field names? Or alternitavely how do I get mysql to an array that only contains fieldnames=value?
Many thanks
Chris Wheat