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
https://forums.phpfreaks.com/topic/229055-why-am-i-not-getting-a-result/
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.

 

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.