Jump to content

Archived

This topic is now archived and is closed to further replies.

Shadow Hatake

Query returns resource id #3

Recommended Posts

[code] <?php

include('dbconnect.php');

$id = $_GET['jid'];
$question = $_GET['q'];

if( isset( $_GET['jid'] ) ) {
     if( isset( $_GET['q'] ) ) {
         $query = 'SELECT '.$question.' FROM boards WHERE id = "'.$id.'"';
        $result = mysql_query( $query );
                    
        if( $result ) {
            echo $result;
        } else {
            echo 'Error';
        }
    } else {
        echo 'Page accessed incorrectly...';
    }
} else {
    echo 'Page accessed incorrectly...';
}

?>[/code]

All I'm getting is resource id #3 when it should be showing the query. Help?

Share this post


Link to post
Share on other sites
Change:

[code]echo $result;[/code]

to:

[code]echo "<table>";
while ($row = mysql_fetch_array($result)) {
  echo "<tr>";
  foreach ($row as $key => $value) {
    echo "<td>$key</td><td>$value</td>";
  }
  echo "<tr>";
}
echo "</table>";[/code]

when you assign $result to mysql_query("some sql") it creates a reference to the object that contains your data. You have to use other php mysql functions to access the data contained inside.

Share this post


Link to post
Share on other sites

×

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.