So, for example, I have this table from my MySQL with a certain record a:
| col1 | col2 | col3 |
a| 0 | 1 | 2 |
I'd like to echo this record in PHP, but I'd not want that column with the zero value to be printed as well. So it would look like this.
| col2 | col3 |
a| 1 | 2 |
The code
$get = "INSERT INTO table (col1, col2, col3) VALUES('0', '1', '2')";
$result = mysql_query($get);
echo "<table><tr><td>col2</td><td>col3</td></tr>";
while ($row = mysql_fetch_array($result)) {
echo"<tr> <td>".$row['col2']." </td>
<td>".$row['col3']."</td>
</tr>";
}
This is the manual execution of the code, but if I had some tens of columns, I'd like the code to detect which columns have zeros, which I'm not familiar with.
Yeah, so basically, I have no idea of the syntax that allows me to loop through all the columns of a given table in MySQL. I'm working with MySQL in PHP