scottmaples Posted April 14, 2009 Share Posted April 14, 2009 i need to know the script to put in my user profiles on my website to let them view thier account balances.... I KNOW THIS IS NOT A HARD THING TO Do but yet I have asked forthe past 2 weeks on other sites and have not had a clear answer: All of my pages are written in php with html bodies! I need to know how to display this on the screen when they are logged in it is user specific so it has to only get that users info and verify that they are logged in and it needs to be secure the database name is scott the table is users the column is Account balance. please clearly state what I need to add to a script or change if you post a script... i need this to be a secure way to do it too please Quote Link to comment https://forums.phpfreaks.com/topic/153949-display-user-specific-data-from-mysql/ Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 When they log in, store their ID/username (if unique) in the session. When they go to view their profile look up their information by the id or username: session_start(); $id = mysql_real_escape_string($_SESSION['id']); //connection info $sql = "SELECT * FROM users WHERE userid = $id"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($result) echo "User " . $_SESSION['id'] . " account balance: " . $row['AccountBalance']; ?> please clearly state what I need to add to a script or change if you post a script... i need this to be a secure way to do it too please Clearly state?? OK, as clear as it can be with the lack of information you provided, you need to change it to work with your script... Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/153949-display-user-specific-data-from-mysql/#findComment-809115 Share on other sites More sharing options...
scottmaples Posted April 14, 2009 Author Share Posted April 14, 2009 ok i want to place the script so it shows in my header next to user name and logout... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en" dir="{DOCDIR}"> <head> <title>{PAGE_TITLE}</title> <meta http-equiv="Content-Type" content="text/html; charset={CHARSET}"> {STYLES} <link rel='stylesheet' type='text/css' href='{SITEURL}themes/default/style.css'> <link rel="stylesheet" type="text/css" href="{SITEURL}themes/default/jquery.lightbox.css" media="screen"> <link rel="alternate" type="application/rss+xml" title="{L_924}" href="{SITEURL}rss.php?feed=1" /> <link rel="alternate" type="application/rss+xml" title="{L_925}" href="{SITEURL}rss.php?feed=2" /> <link rel="alternate" type="application/rss+xml" title="{L_926}" href="{SITEURL}rss.php?feed=3" /> <link rel="alternate" type="application/rss+xml" title="{L_927}" href="{SITEURL}rss.php?feed=4" /> <link rel="alternate" type="application/rss+xml" title="{L_928}" href="{SITEURL}rss.php?feed=5" /> <link rel="alternate" type="application/rss+xml" title="{L_929}" href="{SITEURL}rss.php?feed=6" /> <link rel="alternate" type="application/rss+xml" title="{L_930}" href="{SITEURL}rss.php?feed=7" /> <link rel="alternate" type="application/rss+xml" title="{L_931}" href="{SITEURL}rss.php?feed=8" /> <script type="text/javascript" src="{SITEURL}js/jquery.js"></script> <script type="text/javascript" src="{SITEURL}js/jquery.dimensions.js"></script> <script type="text/javascript" src="{SITEURL}js/jquery.lightbox.js"></script> <script type="text/javascript"> $(document).ready(function() { function window_open(pagina,titulo,ancho,largo,x,y){ alert(0); var Ventana= 'toolbar=0,location=0,directories=0,scrollbars=1,screenX='+x+',screenY='+y+',status=0,menubar=0,resizable=0,width='+ancho+',height='+largo; open(pagina,titulo,Ventana); } $('a.new-window').click(function(){ var posY = ($(window).height()-550)/2; var posX = ($(window).width())/2; window.open(this.href, this.alt, "toolbar=0,location=0,directories=0,scrollbars=1,screenX="+posX+",screenY="+posY+",status=0,menubar=0,width=550,height=550"); return false; }); var currenttime = '{ACTUALDATE}'; var serverdate = new Date(currenttime); function padlength(what){ var output=(what.toString().length==1)? "0"+what : what; return output; } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds()); $("#servertime").html(timestring); } setInterval(displaytime, 1000); $(function() { $('#gallery a').lightBox(); }); }); </script> {EXTRAINC} <meta name="description" content="{DESCRIPTION}"> <meta name="keywords" content="{KEYWORDS}"> </head> <body> <div align="{PAGEALIGN}"> <table width="{PAGEWIDTH}" cellpadding="0" cellspacing="0" border="0" class="container" style="text-align:left;"> <tr> <td> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="logo"> <tbody> <tr> <td width="50%"> {LOGO} </td><td width="50%"> {BANNER} </td> </tr> </tbody> </table> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="counters"> <tr> <td> <span class="leftside"><!-- IF B_LOGGED_IN -->{L_200} {YOURUSERNAME}. <a href="{SSLURL}logout.php?">{L_245}</a><!-- ENDIF --></span> <span class="rightside">{HEADERCOUNTER}</span> <span class="rightside"> <script language="JavaScript"> TargetDate = "04/15/2009 6:00 PM"; BackColor = "transparent"; ForeColor = "black"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </span> </td> </tr> </table> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="navbar"> <tr> <td> <table cellspacing="0" class="table-bar"> <tbody> <tr> <td><a href="{SITEURL}index.php?">{L_166}</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <td><a href="{SITEURL}paypal.php?">Purchase Bids</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <td><a href="http://www.myspace.com/scott_bid">ADD US TO YOUR MYSPACE</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <!-- IF B_CAN_SELL --> <!-- ENDIF --> <!-- IF B_LOGGED_IN --> <td><a href="{SITEURL}user_menu.php?">{L_622}</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <td><a href="{SSLURL}logout.php?">{L_245}</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <!-- ELSE --> <td><a href="{SSLURL}register.php?">{L_235}</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <td><a href="{SSLURL}user_login.php?">{L_052}</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <!-- ENDIF --> <!-- IF B_BOARDS --> <td><a href="{SITEURL}boards.php">{L_5030}</a><div class="imgSep"><img src="{SITEURL}images/transparent.gif" width="10" height="10" alt="spacer"></div></td> <!-- ENDIF --> <td><a href="{SITEURL}faqs.php" alt="faqs" class="new-window">{L_148}</a></td> </tr> </tbody> </table> </td> </tr> </table> <table border="0" class="barSec" style="height:37; width:100%;"> <tr> <td width="50%"> <form name="search" action="{SITEURL}search.php" method="GET"> <div class="barSearch"> <input type="hidden" name=""> {L_103} <input type="text" name="q" size=15 value="{Q}"> <input type="submit" name="" value="{L_275}" class="button"> <a href="{SITEURL}adsearch.php">{L_464}</a> </div> </form> </td> <td width="50%" align="right"> <form name="gobrowse" action="{SITEURL}browse.php" method="GET"> <div class="barBrowse"> {L_104} {SELECTION_BOX} <input type="submit" name="sub" value="{L_275}" class="button"> </div> </form> </td> </tr> </table> again the database name is scott then "users" then "bids" is where the data I want to display is located Quote Link to comment https://forums.phpfreaks.com/topic/153949-display-user-specific-data-from-mysql/#findComment-809174 Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 ok i want to place the script so it shows in my header next to user name and logout... Ok, and what's your question...? P.S. - Use tags around code. Quote Link to comment https://forums.phpfreaks.com/topic/153949-display-user-specific-data-from-mysql/#findComment-809178 Share on other sites More sharing options...
scottmaples Posted April 14, 2009 Author Share Posted April 14, 2009 lol I need to be able to have each user view thier account balance.... i dont know how to do this.....the code for were i would like to have them view it is above i think i explained that part already..... this is the code for how a page pulls data from one of the dtatbases already if it helps any: // get ending soon auctions $query = "SELECT ends, id, title FROM " . $DBPrefix . "auctions WHERE closed = 0 AND suspended = 0 AND starts <= " . $NOW . " ORDER BY ends LIMIT " . $system->SETTINGS['endingsoonnumber']; $res = mysql_query($query); $system->check_mysql($res, $query, __LINE__, __FILE__); $num_auction = mysql_num_rows($res); $i = 0; $bgcolor = '#FFFFFF'; while ($i < $num_auction) { if ($bgcolor == '#FFFFFF') { $bgcolor = '#FFFEEE'; } else { $bgcolor = '#FFFFFF'; } $ends = mysql_result($res, $i, 'ends'); $difference = $ends - time(); if ($difference > 0) { $ends_string = FormatTimeLeft($difference); } else { $ends_string = $MSG['911']; } $template->assign_block_vars('end_soon', array( 'BGCOLOUR' => $bgcolor, 'DATE' => $ends_string, 'ID' => mysql_result($res, $i, 'id'), 'TITLE' => mysql_result($res, $i, 'title') )); $i++; } $end_soon = ($i > 0) ? true : false; Quote Link to comment https://forums.phpfreaks.com/topic/153949-display-user-specific-data-from-mysql/#findComment-809210 Share on other sites More sharing options...
Maq Posted April 14, 2009 Share Posted April 14, 2009 lol I need to be able to have each user view thier account balance.... i dont know how to do this.....the code for were i would like to have them view it is above i think i explained that part already..... this is the code for how a page pulls data from one of the dtatbases already if it helps any: Hmm... I still fail to see a question. Quote Link to comment https://forums.phpfreaks.com/topic/153949-display-user-specific-data-from-mysql/#findComment-809652 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.