php - How can I get the name of the specified field in a result using mysqli functions -
function table($sql,$border) { $con = mysqli_connect("localhost","root","","dbit36"); $resource = mysqli_query($con,$sql); echo"<table border=0>"; for($i = 0; $i < mysqli_num_fields($resource); $i++) { echo "<td style='border:".$border."1px dotted;'><b><font color='990099'size='10'>".mysql_field_name( $resource, $i )."</b></font></td>"; } echo "</tr>"; while($row = mysqli_fetch_array($resource)) { echo "<tr>"; for($i = 0; $i < mysqli_num_fields($resource); $i++) { echo "<td style='border:".$border."px ridge;'>".$row[$i]."</td>"; } echo "</tr>"; } echo "</table>"; }
i know using mysql
function deprecated in php 5.5+ versions thats why question there mysqli
function can name of specified field in result?
by using mysqli_fetch_assoc
instead of mysqli_fetch_array
can select field in table you're fetching typing $row['field_name']
reference: http://php.net/manual/en/mysqli-result.fetch-assoc.php
Comments
Post a Comment