otixz Posted April 26, 2008 Share Posted April 26, 2008 Hi, I really need help I have an array, and a mysql_query... here is the code: $colorList = array($BSAccountancy,$MgntAccounting,$BussMgt,$CompMgt,$Mktg,$OfficeMgt,$CompEduc,$AssComsec,$Mechanical,$Electrical,$Industrial,$Civil,$ECE,$COE,$BioMed,$ElectricalTech,$MechanicalTech,$BSHRM,$AssociateHRM,$BSND,$BSPhsychology,$ABPhsychology,$ABPolSci,$ABMasscom,$ABJournalism,$ABLegalMgt,$BSElemEduc,$BSSecEduc,$CompSci,$ACT,$BSIT,$BSIM,$MaritimeTranspo,$MarineEng,$BasicSeaman,$COLLEGEOFLAW,$EARNINGUNITS,$MEDTRANS,$NURSING,$GRADESCHOOL,$HIGHSCHOOL,$Medicine,$DenstistryProper,$PreDentistry,$DentalHygiene,$DentalTechnology,$PhysicalTherapy,$CPT,$OccupationalTherapy,$Pharmacy,$RadiologicTechnology,$Midwifery); //print_r ($colorList); //select all courses $qry_course = mysql_query("select * from tblcourses where title IS NULL"); $row_course = mysql_num_rows($qry_course); if($row_course=="0"){ } else{ while($d = mysql_fetch_array($qry_course)) { foreach( $colorList as $key => $value) { echo " update tblinquiry set total= '".$value."' where course='".$d['coursename']."' and inq_date='04/20/2008'"; } } } 1.) I want to have a mysql query wherein I can update my tblinquiry dbtable with the $value with the $course. please help... the query should be like this: update tblinquiry set total='<total value>' where course='<coursename>' and inq_date='04/20/2008'. the total value will come from the array the coursename will come from the query Link to comment https://forums.phpfreaks.com/topic/102989-how-to-combine-a-mysql-query-and-an-array/ Share on other sites More sharing options...
Barand Posted April 26, 2008 Share Posted April 26, 2008 You need a way to identify which value belongs to which course. eg $colorList = array ( 'coursenameA' => $valueA, 'coursenameB' => $valueB, etc ); Link to comment https://forums.phpfreaks.com/topic/102989-how-to-combine-a-mysql-query-and-an-array/#findComment-527635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.