mattsolomon Posted February 27, 2011 Share Posted February 27, 2011 at the moment i have my page: addevent.php i have written: $q = "SELECT username " ."FROM ".TBL_USERS." ORDER BY ASC"; $result = $database->query($q); on the database.php page here is what query looks like: /** * query - Performs the given query on the database and * returns the result, which may be false, true or a * resource identifier. */ function query($query){ return mysql_query($query, $this->connection); } then i want to display $result in a drop down menu so i wrote back on addevent.php: <select name="Select1"> <option value="<? echo("$result"); ?>"><? echo("$result"); ?></option> </select> Quote Link to comment Share on other sites More sharing options...
flolam Posted February 27, 2011 Share Posted February 27, 2011 <select name="Select1"> <?php while ($row = mysql_fetch_assoc($result)) { echo '<option value="'.$row["column_name"].'">'.$row["column_name"].'</option>'; } ?> </select> of course you need to replace column_name with the name of the db column from which you want to insert the value. Quote Link to comment Share on other sites More sharing options...
mattsolomon Posted February 27, 2011 Author Share Posted February 27, 2011 im still not getting a result? i've echo'd $q and i get: SELECT * FROM client_details ORDER BY ASC but $result is brining nothing? Quote Link to comment Share on other sites More sharing options...
flolam Posted February 27, 2011 Share Posted February 27, 2011 Shouldn't your sql "order by" clause include a column? like this: SELECT * FROM client_details ORDER BY column ASC Quote Link to comment Share on other sites More sharing options...
mattsolomon Posted February 27, 2011 Author Share Posted February 27, 2011 thank you [solved] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.