Here's my code:
$inv = array('field1','field2','field3','field4');
$sql = "select * from table1 where id='1'";
$result = mysql_query($sql);
if(!$result){
print mysql_error();
}else{
while($row = mysql_fetch_array($result)){
foreach($inv as $i){
print $row[$i];
}
}
}
table1 consist of the following field name: field1, field2, field3, field4, field5, field6, field7
$inv = explode(',',$item) where $item = table2 $row[value] return a string with comma delimited which may consist 'field1,field2,field5' or 'field3,field4,field6'...etc.
How come it only print the value of field1? What's wrong with this code?
while($row = mysql_fetch_array($result)){
print $row['field1'];
print $row['field2'];
print $row['field3'];
print $row['field4'];
}
But if I do this way it will print all the value.
$invis already an array, why are you exploding it. print $i and see what the results are. I bet not what you think.explodeline, which is (was?) the critical point others point out. Are you removing it because it isn't in your actually code?