Jump to content

why am i not getting a result?


mattsolomon

Recommended Posts

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>

 

Link to comment
Share on other sites

<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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.