Jump to content

Display mysql values with php help.


user51

Recommended Posts

I am trying to display a single value on my page and i cant seem to display it for the life of me. can someone tell me if im doing something wrong?

this is what i have so far:

 

<?php
require_once('inc/common.inc.php');

// Connect to the database
db_connect();

// Check and update the authentication.
check_auth();

db("select * from ${db_name}_users where login_id = '$login_id'");
echo "$login_id";

?>

 

obviously there is a field in the database that corresponds to turns and it is int(4),

 

..... Now, i am able to display $login_id, but when i try to display another field, named turns, it just displays a blank page.

Any pointers would be appreciated

thank you.

 

Link to comment
Share on other sites

Echoing $login_id has nothing to do with the database query result. Its value is obviously set before the query attempts to run. Since you are able to echo a value from $login_id, either that code isn't the code you're actually using, or you've not included all the relevant parts.

Link to comment
Share on other sites

that is all the code i have on the page, my goal is to just display that single field value, and use the same code to display other values on the top of the page in separate cells of a table.

 

if you dont mind, how can i call to display that?

again it does echo the user id but no the other cells.

Link to comment
Share on other sites

<?php
require_once('inc/config.inc.php');

$sql = "SELECT `turns` FROM `exodus_users` WHERE 1 LIMIT 0, 30 ";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0) {
while($r = mysql_fetch_assoc($result)) {
echo $r['turns'] . '<br />';
}
}
else {
echo 'No rows returned from the query.';
}

?>

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.