Hi All, I have some problems in the following code please help me..... <?php $query="SELECT * FROM hostel_name"; $res=mysql_query($query) or die(mysql_error()); echo '<select>'; while($row=mysql_fetch_array($res)) { echo '<option value="'.$row['yourfield'].'">'.$row['yourfield'].'</option>'; } echo '</select>'; ?> ERROR COMES: echo '<option value="'.$row['yourfield'].'">'.$row['yourfield'].'</option>'; line ','string should used ',' I am not able to understand what is the actual problem???
echo "<option value=".$row['yourfield'].">".$row['yourfield']."</option>"; i could be wrong, but not sure why you have "'.$row['yourfield']'" dont know why oyu need the ' and " i could be wrong though. also, try echoing it with " instead of '
actually i want to fetch value from 'hostel_name' table into a combo box so i am doing this and 'yourfield' is the field name of that table ' so i am doing this ....... any suggestion will be appreciated. thank you.
<?php $query="SELECT * FROM hostel_name"; $res=mysql_query($query) or die(mysql_error()); echo "<select>"; while($row=mysql_fetch_array($res)) { echo "<option value=\"".$row['yourfield']."\">".$row['yourfield']."</option>"; } echo "</select>"; ?>