Jump to content

[SOLVED] Loop only gets 1 value!


jjmusicpro

Recommended Posts

And it kicks out the results on the page in hyperlinks, all the zipid's are 14, they should be looping through and getting the search_id that matches the zipcode.

 

<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
require_once ('connect.php'); 
require_once ('opendb.php');
$groupid_sent = $_GET['actname'];
$query = "SELECT account_name, company_name, search_id FROM zipcodes WHERE account_name='$groupid_sent' group by account_name"; 
$result = @mysql_query ($query); 
$count = mysql_num_rows($result); //number of results  
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ 
$groupname = $row['groupname'] ;
$account_name= $row['company_name'] ;
$zipid = $row['search_id'] ;
}
}else{ 
require_once ('connect.php'); 
require_once ('opendb.php');  
$groupid_sent = $_GET['groupid'];	
$query = "SELECT account_name, company_name, search_id FROM zipcodes WHERE account_name='$groupid_sent' group by account_name"; 
$result = @mysql_query ($query); 
$count = mysql_num_rows($result); //number of results 
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ 
$groupid_sent= $row['account_name'] ;
$account_name= $row['company_name'] ;
$zip_id = $row['search_id'] ;

}}?> 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mr. Handyman Database Editor 1.0v</title>
</head>
<body>
<?php echo "<h3>$groupid_sent - $account_name </h3>"; ?>
<fieldset>
<a href="index.php">Home</a> || <a href="bulkedits.php?groupid=<?php echo $groupid_sent; ?>">Account</a> || <a href="viewzips.php?groupid=<?php echo $groupid_sent; ?>">Active Zips</a> - <a href="pausedzips.php?groupid=<?php echo $groupid_sent; ?>">Paused Zips</a> || <a href="pause.php?groupid=<?php echo $groupid_sent; ?>">Pause Account</a> || <a href="testzips.php?groupid=<?php echo $groupid_sent; ?>">Test Zips</a>
</fieldset>

<fieldset><a href="addtestzip.php?groupid=<?php echo $groupid_sent; ?>">Add Test Zip</a></fieldset>

<p>
<?php echo "<b>$account_name zips</b>"; ?><br>


<?php
//Paused Clients Query
parse_str("$QUERY_STRING");
$db = mysql_connect("localhost", "mrha_user4","joefox") or die("Could not connect.");
if(!$db) 
die("no db");
if(!mysql_select_db("mrha_db4",$db))
die("No database selected."); 
$acc1="SELECT * from zipcodes WHERE account_name='$groupid_sent' and on_off=1";
$acc2=mysql_query($acc1) or die("Could not select paused clients.");
while($acc3=mysql_fetch_array($acc2)) {
echo "<a href=editzips.php?groupid=$groupid_sent&zipid=$zip_id>Edit</a> || <a href=pausezip.php?groupid=$groupid_sent&zipid=$zip_id>Pause</a> - $acc3[zipcode] - $acc3[city] <br>"; 
}
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/71559-solved-loop-only-gets-1-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.