Solved

Select statement not outputing

Posted on 2009-04-07
2
201 Views
Last Modified: 2012-05-06
This is some really basic script, but for some reason my select box is not outputting my query results.  I must be going crazy because normally I can figure these out quite quickly, but I'm stumped.  I know it is something very simple (as always), but I can't pin point it.

<div class="">
                              <?php
                                    $getCats = sprintf("SELECT category
                                          FROM main_categories
                                          ORDER BY category");
                                    $catsGot = mysql_query($getCats) or die("Cats did not get because: " . mysql_error);
                              ?>
                              <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
                                    <select name="category">
                                          <?php
                                                while($m = mysql_fetch_array($catsGot)) {
                                                      echo "<option value='<?= {$m['category']} ?>'><?= {$m['category']} ?></option>";
                                                }
                                          ?>
                                    </select>
                              </form>
                        </div>
0
Comment
Question by:pingeyeg
2 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 250 total points
ID: 24093082
It's probably because of this line:

 echo "<option value='<?= {$m['accountID']} ?>'><?= {$m['accountID']} ?></option>";

Try;

 echo "<option value='" . $m['accountID'] . "'>" . $m['accountID'] . "</option>";
0
 
LVL 1

Author Comment

by:pingeyeg
ID: 24093103
Like I said.  That was simple.  I do that all the time.  Argh!!  Thanks
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question