Jump to content

Problem with first item of while loop


jimleeder123

Recommended Posts

I have a while loop that does everything I need for all items except the first one echoed out. It doesn't get the form tags, but every other one does. My code is below, can anyone help?

 

$cats = "SELECT cat_name FROM categories";
                    $catsres = mysql_query($cats) or die(mysql_error());
                    
                    echo "<div class='categorymenu'>";
                    
                    while ($catrow = mysql_fetch_array($catsres)) {
                    
                        
                        
                        echo "<div class='categoryline'>";
                            echo "<form method='post' action='products.php'>";
                                
                                echo "<input type='submit' value='";
                                echo $catrow['cat_name'];
                                echo "' />";
                                
                                echo "<input type='hidden' name='category' value='";
                                echo $catrow['cat_name'];
                                echo "'  />";
                                
                            echo "</form>";
                        echo "</div>";
                    }
                    
                    echo "</div>";

Link to comment
https://forums.phpfreaks.com/topic/296857-problem-with-first-item-of-while-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.