marksie1988 Posted May 7, 2010 Share Posted May 7, 2010 Hiu Guys, having a bit ov an issue with this havent had to do anything like this before but here goes below you will see my php code which calls all of the tickets from hd_ticket and then explodes the email address to get the domain.com once it has this i need to select the domain.com from the hd_customers table and update the hd_ticket table company column with the information from the hd_customers table. for some reason when it runs the nested while loop it doesnt loop through all of the results it only displays one on the echo i have also put my table structure to help you out. hd_customers id email company 1 domain.com mycompany hd_tickets ticket_id ticketID dept_id priority_id topic_id staff_id email name subject helptopic phone phone_ext ip_address status source isoverdue isanswered duedate reopened closed lastmessage lastresponse created updated company $sql= 'SELECT * FROM hd_ticket '; $result = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ $fromco = explode("@",$row[email]); $fromco = $fromco[1]; $sql= 'SELECT * FROM hd_customer WHERE email="'.$fromco.'"' ; $result = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ $company = $row[company] ; $sql= 'UPDATE hd_ticket ticket SET ticket.company='.$company.''; print $sql; //mysql_query($sql); } } //} Link to comment https://forums.phpfreaks.com/topic/201019-issues-with-nested-while-loop/ Share on other sites More sharing options...
kenrbnsn Posted May 7, 2010 Share Posted May 7, 2010 You're reusing the variable $result within the loop. Use a different variable for the second mysql_query() statement. Ken Link to comment https://forums.phpfreaks.com/topic/201019-issues-with-nested-while-loop/#findComment-1054667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.