user51 Posted September 25, 2010 Share Posted September 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/214372-display-mysql-values-with-php-help/ Share on other sites More sharing options...
Pikachu2000 Posted September 25, 2010 Share Posted September 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/214372-display-mysql-values-with-php-help/#findComment-1115569 Share on other sites More sharing options...
user51 Posted September 25, 2010 Author Share Posted September 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/214372-display-mysql-values-with-php-help/#findComment-1115570 Share on other sites More sharing options...
user51 Posted September 25, 2010 Author Share Posted September 25, 2010 <?php require_once('inc/config.inc.php'); $sql = "SELECT `turns` FROM `exodus_users` WHERE 1 LIMIT 0, 30 "; echo "turns"; ?> the above $sql i pulled from phpmyadmin, config.inc.php has the login info. i still get just the word turns echoed, help Quote Link to comment https://forums.phpfreaks.com/topic/214372-display-mysql-values-with-php-help/#findComment-1115572 Share on other sites More sharing options...
jcbones Posted September 26, 2010 Share Posted September 26, 2010 <?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.'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/214372-display-mysql-values-with-php-help/#findComment-1115696 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.