neex1233 Posted June 29, 2009 Share Posted June 29, 2009 Hi, how could I make a PHP script where when you check a select box it will get the user's email from a MySQL database and display it on the user profile? Thanks! This is an idea of what I will use: <?php $con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ' . mysql_error()); mysql_select_db("DB_Name", $con); $username = mysql_real_escape_string($_SESSION["username"]); $sql = " SELECT * FROM `users` WHERE username = '$username' LIMIT 0, 30 "; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $email = $row['email']; } echo "$email"; ?> Link to comment https://forums.phpfreaks.com/topic/164031-show-email-on-profile/ Share on other sites More sharing options...
killah Posted June 29, 2009 Share Posted June 29, 2009 <?php session_start(); $con = mysql_connect("localhost", "Username", "Password") or die('Could not connect: ', mysql_error()); mysql_select_db("DB_Name", $con); $username = mysql_real_escape_string($_SESSION["username"]); $SQL = 'SELECT `email` FROM `users` WHERE `username` = ', $username, ' LIMIT 0, 30'; $result = mysql_query($SQL) or die('Error in sql: ', mysql_error());+ $args = array(); while($soc = mysql_fetch_assoc($args)) { $args[] = $soc['email']; } echo implode('<br />', $args); ?> Maybe? Link to comment https://forums.phpfreaks.com/topic/164031-show-email-on-profile/#findComment-865327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.