PDA

View Full Version : echoing php data


theman68
04-25-2011, 01:49 PM
i have a website all set up and ready to go almost just got a few issues left.
one of the biggest ones puzzling me for a while is i have sections of the website that is log in ect and i have a ' you are signed in as : johnny' for instance from the record set but it just show the first insert into the data base and i dont know how to filter the info to the personal info to that user.
i know all i know have to do it to set the filter the record set but every time i try to do it, it doesnt seem to work. can you guys please help me with this is a big problem for me at the mo thanks.

edbr
04-26-2011, 12:54 AM
it sounds like you need a select statement select * from table where id =

you have to edit the table name and field (id) to the correct database set up you have and it must equal the value of the members info

theman68
04-26-2011, 01:11 AM
hi mate i am a total novice at this part of things so ill just post you my code and let you see:


<?php require_once('Connections/jettsongs_user.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "LirikWearEnglish/Products.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "LirikWearEnglish/Login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$colname_Recordset1 = "-1";
if (isset($_GET['user_name'])) {
$colname_Recordset1 = $_GET['user_name'];
}
mysql_select_db($database_jettsongs_user, $jettsongs_user);
$query_Recordset1 = sprintf("SELECT user_name, f_name, Lname, a, sex, add1, add2, city, `state`, cntry, zip, phoneNo, email FROM users WHERE user_name = %s ORDER BY user_name ASC", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $jettsongs_user) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
mysql_select_db($database_jettsongs_user, $jettsongs_user);
$query_Recordset1 = "SELECT * FROM users ORDER BY user_name ASC";
$Recordset1 = mysql_query($query_Recordset1, $jettsongs_user) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Welcome To Lirik Wear</title>
<meta name="keywords" content="lirik, lirik wear, bikinis, lingerie, sexy lingerie, sexy wear, ladies underwear, ladies lingerie, bras, knickers, panties, sexy and elegant, elegant wear, lyric wear, elegant bras, elegant lingerie, swimwear, ladies bikinis, girls bikinis, ladies wear" />
<meta name="description" content="Lirik Wear. We have some of the best quality design's and best quality stitched suit's around for the lowest price's for high quality goods.We have Bikini's, All Types of Swimwear and will soon have a large rage of ladie's underwear and sexy accsessories" />
<link href="css/default.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv1 {
position:absolute;
width:100px;
height:50px;
z-index:1;
left: 368px;
top: 30px;
clip: rect(450px,200px,auto,auto);
margin-right: 2px;
margin-bottom: 10px;
margin-left: 2px;
margin-top: 2px;
}
</style>


<script type="text/javascript" src="js/alert12.js"></script>


<script type="text/javascript" src="js/prototype.js"></script>

<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>

<script type="text/javascript" src="js/lightbox.js"></script>

<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="css/jkmegamenu.css" />

<script type="text/javascript" src="js/jkmegamenu.js">

/***********************************************
* jQuery Mega Menu- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for full source code
***********************************************/

</script>
<script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
<script type="text/javascript">
//jkmegamenu.definemenu("anchorid", "menuid", "mouseover|click")
jkmegamenu.definemenu("megaanchor", "megamenu1", "mouseover")
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
</script>

<link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
</head>
<body onload="MM_preloadImages('SF/all pics/socil networking over.png','SF/SNicons/facebook.png','SF/SNicons/flickr.png','SF/SNicons/friendFeed.png','SF/SNicons/youtube.png','SF/SNicons/lastFM.png','SF/SNicons/LinkedIn.png','SF/SNicons/twitter.png')">
<div id="bgLogo">
<div id="header">
<div id="logo">
<h1>Lirik Wear </h1>
<h2>Sexy and elegant</h2>
</div>
<div id="menu">
<ul>
<li><a href="LirikWearEnglish/Signed In/HomeSI.php">Home</a></li>
<li class="active"><a href="LirikWearEnglish/Signed In/ProductsSI.php">Products</a></li>
<li><a href="LirikWearEnglish/Signed In/ProductionSI.php">Production</a></li>
<li><a href="LirikWearEnglish/Signed In/PartnersSI.php">partners</a></li>
<li><a href="LirikWearEnglish/Signed In/LinksSI.php">Links</a></li>
<li><a href="LirikWearEnglish/Signed In/ContactSI.php">Contact Us</a></li>
</ul>
</div>
</div>
<div id="content">
<div id="sM"><!--Mega Menu Anchor-->
<a href="#" id="megaanchor" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','SF/all pics/socil networking over.png',1)"><img src="SF/all pics/socil networking.png" alt="Social Networking" width="92" height="24" border="0" align="absmiddle" id="Image7" /></a>


<!--Mega Drop Down Menu HTML. Retain given CSS classes-->
<div id="megamenu1" class="megamenu">

<div class="column">
<ul>
<li><a href="www.facebook.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('FaceBook','','SF/SNicons/facebook.png',1)"><img src="SF/SNicons/facebook.png" alt="FaceBook" width="32" height="31" border="1" id="FaceBook" /></a></li>
<li><a href="www.Flickr.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Flickr','','SF/SNicons/flickr.png',1)"><img src="SF/SNicons/flickr.png" alt="Flickr" width="32" height="31" border="1" id="Flickr" /></a></li>
<li><a href="www.friendfeed.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('FriendFeed','','SF/SNicons/friendFeed.png',1)"><img src="SF/SNicons/friendFeed.png" alt="FriendFeed" width="32" height="31" border="1" id="FriendFeed" /></a></li>
<li><a href="www.youtube.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('YouTube','','SF/SNicons/youtube.png',1)"><img src="SF/SNicons/youtube.png" alt="YouTube" width="32" height="31" border="1" id="YouTube" /></a></li>
<li><a href="www.lastfm.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('LastFM','','SF/SNicons/lastFM.png',1)"><img src="SF/SNicons/lastFM.png" alt="LastFM" width="32" height="31" border="1" id="LastFM" /></a></li>
<li><a href="www.linkedin.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('LinkedIn','','SF/SNicons/LinkedIn.png',1)"><img src="SF/SNicons/LinkedIn.png" alt="LinkedIn" width="32" height="31" border="1" id="LinkedIn" /></a></li>
<li><a href="www.twitter.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Twitter','','SF/SNicons/twitter.png',1)"><img src="SF/SNicons/twitter.png" alt="Twitter" width="32" height="31" border="1" id="Twitter" /></a></li>
<li><a href="www.tagged.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Tagged','','SF/SNicons/tagged.png',1)"><img src="SF/SNicons/tagged.png" alt="Tagged" width="32" height="32" border="1" id="Tagged" /></a></li>
<li><a href="www.myspace.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('MySpace','','SF/SNicons/myspace.png',1)"><img src="SF/SNicons/myspace.png" alt="MySpace" width="32" height="32" border="1" id="MySpace" /></a></li>
<li><a href="www.hi5.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Hi5','','SF/SNicons/hi5.png',1)"><img src="SF/SNicons/hi5.png" alt="Hi5" width="32" height="32" border="1" id="Hi5" /></a></li>
</ul>
</div>
</div>
<div id="languages" align="right"><div id="siggnedIn"><h4>You are signed in as : <div align="left"><?php echo $row_Recordset1['user_name']; ?></h4>
</div><li><a href="LirikWearChinese/Signed In/ProductsSI.php"> 中文 </a></li></div>
<p></p>
<div id="colOne3"></div>
<div id="colTwo">
<div id="CollapsiblePanel1" class="CollapsiblePanel">
<div class="CollapsiblePanelTab2" tabindex="0">My Account</div>
<div class="CollapsiblePanelContent">
<div id="loginD">
<table border="0">
<tr>
<th scope="col"><div align="left">User Name:</div></th>
<th scope="col"><div align="left"><?php echo $row_Recordset1['user_name']; ?></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Name:</div></th>
<td><div align="left"><?php echo $row_Recordset1['f_name']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Last Name: </div></th>
<td><div align="left"><?php echo $row_Recordset1['Lname']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Age: </div></th>
<td><div align="left"><?php echo $row_Recordset1['a']; ?></div></td>
<br />
</tr>
<tr>
<th scope="row"><div align="left">Sex: </div></th>
<td><div align="left"><?php echo $row_Recordset1['sex']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Address Line 1:</div></th>
<td><div align="left"><?php echo $row_Recordset1['add1']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Address Line 2:</div></th>
<td><div align="left"><?php echo $row_Recordset1['add2']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">City:</div></th>
<td><div align="left"><?php echo $row_Recordset1['city']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">State:</div></th>
<td><div align="left"><?php echo $row_Recordset1['state']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Contry:</div></th>
<td><div align="left"><?php echo $row_Recordset1['cntry']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Postal Code:</div></th>
<td><div align="left"><?php echo $row_Recordset1['zip']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Phone Number:</div></th>
<td><div align="left"><?php echo $row_Recordset1['phoneNo']; ?></div></td>
</tr>
<tr>
<th scope="row"><div align="left">E-Mail:</div></th>
<td><div align="left"><?php echo $row_Recordset1['email']; ?></div></td>
</tr>
</table>
<a href="<?php echo $logoutAction ?>">Log out</a> </div>
</div>
</div>
<ul>
<li>
<form method="get" action="#">
<div>
<input type="text" id="textfield1" name="textfield1" value="" size="18" />
<input type="submit" id="submit1" name="submit1" value="Search" />
</div>
</form>
</li>
<li>
<h2>Latest News</h2>
<ul>
<li><a href="#" id="march" onclick="MM_popupMsg('Page Comming Soon')">March 2011</a></li>
<li><a href="#" id="april" onclick="MM_popupMsg('Page Comming Soon')">April 2011</a></li>
<li><a href="#" id="may" onclick="MM_popupMsg('Page Comming Soon')">May 2011</a></li>
<li><a href="#" id="june" onclick="MM_popupMsg('Page Comming Soon')">June 2011</a></li>
<li><a href="#" id="july" onclick="MM_popupMsg('Page Comming Soon')">July 2011</a></li>
<li><a href="#" id="august" onclick="MM_popupMsg('Page Comming Soon')">August 2011</a></li>
<li><a href="#" id="september" onclick="MM_popupMsg('Page Comming Soon')">September 2011</a></li>
<li><a href="#" id="october" onclick="MM_popupMsg('Page Comming Soon')">October 2011</a></li>
<li><a href="#" id="november" onclick="MM_popupMsg('Page Comming Soon')">November 2011</a></li>
<li><a href="#" id="december" onclick="MM_popupMsg('Page Comming Soon')">December 2011</a></li>
<li><a href="#" id="january" onclick="MM_popupMsg('Page Comming Soon')">January 2012</a></li>
<li><a href="#" id="february" onclick="MM_popupMsg('Page Comming Soon')">February 2012</a></li>
</ul>
</li>
<li>
<h2>Categories</h2>
<ul>
<li><a href="#" id="ComingSoon1" onclick="MM_popupMsg('Page Comming Soon')">Bikinis</a>(20)</li>
<li><a href="#" id="ComingSoon2" onclick="MM_popupMsg('Page Comming Soon')">Lingerie</a></li>
<li><a href="#" id="ComingSoon3" onclick="MM_popupMsg('Page Comming Soon')">Men's Swim Wear</a></li>
<li><a href="#" id="ComingSoon4" onclick="MM_popupMsg('Page Comming Soon')">Men's Wear</a></li>
<li><a href="#" id="ComingSoon5" onclick="MM_popupMsg('Page Comming Soon')">Children's Swim Wear</a></li>
<li><a href="#" id="ComingSoon6" onclick="MM_popupMsg('Page Comming Soon')">Children's Wear</a></li>
<li><a href="#" id="ComingSoon7" onclick="MM_popupMsg('Page Comming Soon')">Ladies Accessories</a></li>
<li><a href="#" id="ComingSoon8" onclick="MM_popupMsg('Page Comming Soon')">Other Brands/Products</a></li>
</ul>
</li>
<li>
<h2>Privilaged Members</h2>
<ul>
<li><a href="#" id="ComingSoon9" onclick="MM_popupMsg('Page Comming Soon')">Advertise Your Own Brand</a></li>
<li><a href="#" id="ComingSoon10" onclick="MM_popupMsg('Page Comming Soon')">Get Great Discount On Bulk Orders</a></li>
<li><a href="#" id="ComingSoon11" onclick="MM_popupMsg('Page Comming Soon')">Free Advertising For Your Brand</a></li>
<li><a href="#" id="ComingSoon12" onclick="MM_popupMsg('Page Comming Soon')">Others</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="footer">
<p>Copyright &copy; 2006 Thunder. Designed by <a href="http://www.freecsstemplates.org/"><strong> CSS Templates</strong></a></p>
</div>
</div>
<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
</script>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

i hope this helps.

theman68
04-26-2011, 01:16 AM
once again thanks for your help
but in all honesty i could really do with a short walk through of how to set it up from word go.
ie i have my database connection set up already so this is what im wanting to do.
i would think its a session variable as you suggested and then from there setting up the record set from scratch and then echoing it and i and any of the details in between i wouldn't know lol cos i followed so many tuts on dw to get this up and running. hope you understand what i mean lol cos im a little stuch for words to explain what i mean. thanks