not getting all the results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Obadiah
Forum Regular
Posts: 580
Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:

not getting all the results

Post by Obadiah »

i was trying to pull up all the records cor this one user based on his user name but it only pulls up one...can someone help me...heres my code

Code: Select all

<?php 
session_start();
function doDB()
{
	$conn = mysql_connect("######","####","######") or die(mysql_error());
	mysql_select_db("customerdirectory",$conn) or die(mysql_error());
	return $conn;
}

function clearsessionscookies() 
{ 
    unset($_SESSION['auth']); 
    unset($_SESSION['logname']); 
     
    session_unset();     
    session_destroy(); 
} 
error_reporting(E_ALL); 
ini_set('display_errors', 1); 
$conn = doDB();
$sql = "Select * FROM merchant WHERE user_name = '{$_SESSION['logname']}'";
$result = mysql_query($sql,$conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result))
{
	$merchant_num = $newArray['merchant_num'];
	$date_recieved= $newArray['date_recieved'];
	$merchant_name = $newArray['merchant_name'];
	$bank= $newArray['bank'];
	$purchase_type= $newArray['purchase_type'];
	$date_submitted= $newArray['date_submitted'];
	$bankap_date= $newArray['bankap_date'];
	$lease_company= $newArray['lease_company'];
	$app_id= $newArray['app_id'];
	$hypercom_tid= $newArray['hypercom_tid'];
	$lease_discount= $newArray['lease_discount'];
	$amexdate_submit= $newArray['amexdate_submit'];
	$amexdate_appd= $newArray['amexdate_appd'];
	$shipped= $newArray['shipped'];
	$terminal= $newArray['terminal'];
	$serial_num= $newArray['serial_num'];
	$nms= $newArray['nms'];
	$comments= $newArray['comments'];
}
echo"
<html>
<head>
<title></title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"cs.css\">
<script language=\"javascript\" src=\"myForms.js\">
</script>
</head>
<body bgcolor=\"white\">
<h3><center>Merchant Services Incorporated</center></h3>
<table width=\"1187\">
<tr>
<td>
<table class=\"text\" width=\"1174\" border=\"1\" bordercolor=\"green\">
<tr>
<td align=\"center\" width=\"75\">Date Received</td>
<td align=\"center\" width=\"81\">Merchant Name</td>
<td align=\"center\" width=\"40\">Bank</td>
<td align=\"center\" width=\"106\">Lease/Conversion/Reprogram</td>
<td align=\"center\" width=\"106\">Date Submitted</td>
<td align=\"center\" width=\"105\">Bank AP Date</td>
<td align=\"center\" width=\"111\">Lease Company</td>
<td align=\"center\" width=\"99\">Lease Discount</td>
<td align=\"center\" width=\"105\">AMEX Date Submit</td>
<td align=\"center\" width=\"109\">AMEX Date APPD</td>
<td align=\"center\" width=\"75\">Shipped</td>
<td align=\"center\" width=\"97\">Merchant Number</td>
</tr>
<tr>
<td>$date_recieved &nbsp;</td>
<td>$merchant_name &nbsp;</td>
<td>$bank &nbsp;</td>
<td>$purchase_type &nbsp;</td>
<td>$date_submitted &nbsp;</td>
<td>$bankap_date &nbsp;</td>
<td>$lease_company &nbsp;</td>
<td>$lease_discount &nbsp;</td>
<td>$amexdate_submit &nbsp;</td>
<td>$amexdate_appd &nbsp;</td>
<td>$shipped &nbsp;</td>
<td>$merchant_num &nbsp;</td>
</tr>
<tr>
<td bgcolor=\"green\" colspan=\"12\">&nbsp;</td>
</tr>
<tr>
<td width=\"45\">Terminal:</td><td width=\"104\">$terminal &nbsp;</td>
<td width=\"73\">Serial Number:</td><td width=\"102\">$serial_num &nbsp;</td>
<td width=\"42\">App-ID:</td><td width=\"114\">$app_id &nbsp;</td>
<td width=\"29\">NMS:</td><td width=\"109\">$nms &nbsp;</td>
<td width=\"70\">Hypercom TID:</td><td>$hypercom_tid &nbsp;</td>
</tr>
<tr>
<td>Comments</td>
<td colspan=\"11\">$comments&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Well, your echo is outside of your while loop and it doesn't use a loop. So the maximum you'd possibly get is a single record. The last one found.
User avatar
Obadiah
Forum Regular
Posts: 580
Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:

Post by Obadiah »

now how did i know you were gonna say that...

*sigh...i hate loops...fine ill try it...dont ask me to like it :P
Post Reply