I am trying to get the column names and field values from a table for ONE record. If a column name was 'sellers' and the field value was 'Bob', the desired output would be: seller Bob
The output will actually be used for a script like this: $fields['sellers']->setValue($sellers);
Where 'sellers' is the column name and $sellers is the field value.
There are dozens of columns in the table.
The script below only outputs the column names - not the field values.
Any help is appreciated.
$sql = "SELECT * FROM tbl_pdfform WHERE trans_id = '$trans_id' ";
$sql_result = mysqli_query($db, $sql);
for($i = 0; $i < mysqli_num_fields($sql_result); $i++) {
$field_info = mysqli_fetch_field($sql_result);
$col = "{$field_info->name}";
echo $col . ' ';
while ($row = mysqli_fetch_array($sql_result)) {
$data = $row[$col];
echo $data."<br>";
}
}