gordonp Posted August 30, 2013 Share Posted August 30, 2013 (edited) I would like a general question answered for a self-taught php freak wanna-be. I have successfully made my sql db, I have made great login and member pages. BUT, now I want to reflect data of the logged in member on the member page. Just like when you log into your credit card page, it shows YOUR current balance, previous balance, date you opened the account, etc. Mine would show (and these are columns of data per member on my database).... Contract Date: Contract Expiration Date: Amount Paid: Contract Download (I want this pdf icon, when clicked, to download the contract that is stored as an object on my db. I can handle the html a href side okay) What is the php or html that would be used for "calling" (or whatever the term here is) this data on the current logged in member's page? Thanks! Edited August 30, 2013 by gordonp Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/ Share on other sites More sharing options...
Azerex Posted May 8, 2014 Share Posted May 8, 2014 (edited) well you would want to do something like this // Database Variables define('DB_HOST', 'Database Host (Normally "localhost" if your script is on the same ip as the db'); define('DB_USER', 'Database User'); define('DB_PASSWORD', 'Database Password'); define('DB_DATABASE', 'Database Name');; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $table = "table you are pulling data from"; $query = "SELECT * FROM `table_name` WHERE account = 'account'"; //This is just an example where you can replace account with any column $result = mysql_query($query) or die(mysql_error()); //Grab Information from query if (mysql_numrows ($result) >= 1) { $rows = mysql_fetch_array ($result, MYSQL_ASSOC); foreach($rows AS $k => $v) { $$k = $v; } echo $Account_Paid; //assuming that that Account_Paid is a column name. You can do this with any of your column names in the database. //you might need to change your file extension to .php in order to insert the variable on the page where you want to show the data unless you want to use something like Smarty. //this can be it's own independent file if you want as well all you have to do is do include('path/to/this.php'); and then insert your variables. } Edited May 8, 2014 by Azerex Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/#findComment-1478690 Share on other sites More sharing options...
cyberRobot Posted May 8, 2014 Share Posted May 8, 2014 Just in case you're not aware, the mysql_* functions have been deprecated. You'll be better off switching to MySQLi or PDO. More information can be found here: http://www.php.net/manual/en/mysqlinfo.api.choosing.php Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/#findComment-1478720 Share on other sites More sharing options...
Azerex Posted May 8, 2014 Share Posted May 8, 2014 (edited) I am aware, sorry, this code is a snippet from one of my older programs so I didn't go through and fix any deprecated functions. Edited May 8, 2014 by Azerex Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/#findComment-1478798 Share on other sites More sharing options...
cyberRobot Posted May 9, 2014 Share Posted May 9, 2014 I am aware, sorry, this code is a snippet from one of my older programs so I didn't go through and fix any deprecated functions. No problem, the comment was more directed at gordonp. It kind of sounds like he/she is just starting out with database programming and it's easier to make the switch now vs down the road. Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/#findComment-1478860 Share on other sites More sharing options...
Clarkey Posted May 9, 2014 Share Posted May 9, 2014 (edited) Are you visitors authenticated by a login system? Do you have a session system setup? If so, you can just do a SQL query using a WHERE clause based on some identifier from your $_SESSION array, such as a username or id (depends on how you've set it up) and then get the SQL array and echo them out where they need to go. Edited May 9, 2014 by Clarkey Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/#findComment-1478861 Share on other sites More sharing options...
mac_gyver Posted May 9, 2014 Share Posted May 9, 2014 lol, this is an older thread that Azerex bumped and the OP never returned to this site after the moment he started/edited the first post in the thread. Link to comment https://forums.phpfreaks.com/topic/281701-reflecting-database-info-on-the-members-page/#findComment-1478875 Share on other sites More sharing options...
Recommended Posts