Note that there are some explanatory texts on larger screens.

plurals
  1. POmysqli_fetch_field() outputs field names multiple times
    text
    copied!<p>I am trying to display the column names from my database and i am able to do this with the <code>mysqli_fetch_field()</code>function, however my issue is that it outputs the column names several times when i only want it to output each of the column names once. I have my <code>$field_info</code> variable set to the that function that takes the parameter <code>$result</code> which is set to my query and all of that is placed into my while loop. I have a feeling that this might be caused by my while loop? but i am not too sure.</p> <pre><code>$query = "SELECT * FROM bodyshops_master_network"; if ($result = $mysqli-&gt;query($query)) { // print the column names as the headers of a table while ($field_info = mysqli_fetch_field($result)) { printf("postcodes_covered %s\n", $field_info-&gt;postcodes_covered); printf("dealer_code %s\n", $field_info-&gt;dealer_code); printf("dealer_name %s\n", $field_info-&gt;dealer_name); printf("bodyshop_id %s\n", $field_info-&gt;bodyshop_id); printf("bodyshop_name %s\n", $field_info-&gt;bodyshop_name); printf("address1 %s\n", $field_info-&gt;address1); printf("address2 %s\n", $field_info-&gt;address2); printf("address3 %s\n", $field_info-&gt;address3); printf("address4 %s\n", $field_info-&gt;address4); printf("address5 %s\n", $field_info-&gt;address5); printf("postcode %s\n", $field_info-&gt;postcode); printf("BO_tel %s\n", $field_info-&gt;BO_tel); printf("BO_email %s\n", $field_info-&gt;BO_email); printf("BC_name %s\n", $field_info-&gt;BC_name); printf("equity_contract %s\n", $field_info-&gt;equity_contract); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload