Get column information from results of mysql query in php? -
i trying print out column headers query entered. have other code connects database , prints results, having trouble line
'$result .= $heading->name;'
i keep getting error:
'catchable fatal error: object of class mysqli_result not converted string in...'
could explain problem is? according php manual should give me right information. new php though, if improve code please explain how did it?
i have following code far gets result query:
$result = mysqli_query($conn,$query); if($result){ if( mysqli_num_rows($result)>0){ $columnno = mysqli_num_fields($result); for($i=0;$i<$columnno;$i++){ $heading = mysqli_fetch_field_direct($result,$i); $result .= $heading->name; } } }
$result
object being used mysqli. try append string onto end of it.
just use different variable name besides $result
string in collect names of columns. or might save names in array this:
$var[] = $heading->name;
Comments
Post a Comment