otixz Posted April 26, 2008 Share Posted April 26, 2008 Hi, I have a msyql query here. How Can I make the query result into array? $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)) { //I want to make $d['coursename'] as an array. echo $d['coursename']; } } 2.) also, I have another array named, $colorlist. My question is how can I create a query that can join the $colorList array and the $d['coursename'] array together in one query. the query that I want to produce is: update tbl set color as $colorlist where course='$d['coursename']'; // Please remember that I have two array. please help! Link to comment https://forums.phpfreaks.com/topic/102997-solved-how-to-make-a-mysql_fetch_array-results-into-array/ Share on other sites More sharing options...
mrdamien Posted April 26, 2008 Share Posted April 26, 2008 while($d = mysql_fetch_array($qry_course)) { $coursenames[] = $d['coursename']; // Adds $d['coursename'] into the $coursenames array echo $d['coursename']; } You just need to find out which index for both the $coursenames and $colorList arrays point to your desired values, then your query will just look like this: "UPDATE tbl SET color = '{$colorlist[$colorIndex]}' where course='{$coursenames[$courseIndex]}'" Link to comment https://forums.phpfreaks.com/topic/102997-solved-how-to-make-a-mysql_fetch_array-results-into-array/#findComment-527622 Share on other sites More sharing options...
otixz Posted April 26, 2008 Author Share Posted April 26, 2008 wow! that really solved my prob! thank you very much! Link to comment https://forums.phpfreaks.com/topic/102997-solved-how-to-make-a-mysql_fetch_array-results-into-array/#findComment-527633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.