Solved

Select statement not outputing

Posted on 2009-04-07
2
204 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 35

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

679 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