Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

in php array fetch all rowsfrom mysql database and all values are showing into the single table td? i Want results like this?

1) Small
2) Large
3) Medium

now problem is that all values displaying into single table td i want to display all of these values into separately table td

Query Function

function get_size($id){
$result=mysql_query("SELECT size FROM mywishlist order by id") 
or die("My Wish Size Problem"."<br/><br/>".mysql_error());
$results = array();
while($row=mysql_fetch_array($result)){
$results[] = stripslashes($row['size'])."<br />";
}
return $results;
}

<td><font style="font-family:Arial,Helvetica,sans-serif;  
font-size:15px; color:#000;">
<?php 
foreach($size as $sizes) {
echo $sizes; }
?></font><input type="hidden" name="size" value="<?php echo $size;?>" /></td>  
share|improve this question

3 Answers

<?php foreach ($size as $sizes) { ?>
    <td><font style="font-family:Arial,Helvetica,sans-serif;font-size:15px; color:#000;">
        <?php echo $sizes; ?> 
        </font><input type="hidden" name="size" value="<?php echo $size; ?>" /></td>  
<?php } ?>
share|improve this answer

You are displaying all data in the same td. You have to make following chages:

<?php 
foreach($size as $sizes) { ?>
    <td>
    <font style="font-family:Arial,Helvetica,sans-serif; font-size:15px; color:#000;">
    <?php echo $sizes;?>
    </font>
   <input type="hidden" name="size" value="<?php echo $size;?>" /></td>
<?php } ?>

Also i would like to suggest to write styles on a style sheet

share|improve this answer
<?php foreach ($sizes as $size) { ?>
   <td>
     <font style="font-family:Arial,Helvetica,sans-serif;font-size:15px; color:#000;">
       <input type="hidden" name="size" value="<?php echo $size; ?>" />
     </font>
   </td>  
<?php } ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.