I have this query: SHOW COLUMNS FROM mash which works fine in my while loop for building a select element made from table column names. But in my table i have “id” and “tstamp” which i dont want in the select element, is this possible to exclude these columns?
echo "<form action='".$_SERVER['PHP_SELF']."' method='get'>";
connectDB();
$result = mysql_query("SHOW COLUMNS FROM mash") or die(mysql_error());
echo '<select name="column" class="column">';
while ($row = mysql_fetch_array($result)) {
echo "<option value='".$row[0]."'>".ucwords($row[0])."</option>";
}
closeConn();
echo '</select>';
echo "</form>";
PHP Way:
Use a
continuein the while loop, when those fields are fetched, like this:This will just skip the
idandtstampfields and process all others.continueis used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration.MySQL Way:
Remove those fields in the query like this: