"Compiling" Results from a Query

From: Date: Mon, 09 Oct 2000 07:11:10 +0000
Subject: "Compiling" Results from a Query
Groups: php.general 
Request: Send a blank email to php-general+get-19152@lists.php.net to get a copy of this message
Hi... I have a form that users check off boxes. The boxes are numbered project1, project2, project3, etc. When the form is processed, I want those project1, project2, project3, etc. to be compiled into one string so it would be something like: $compile="$project1, $project2, $project3"; Then, I can insert these into my database as one field. The problem is that the number of projects can be different on each form submission... i.e., someone can choose 1 project or 8 if they like... so the $compile needs to be dynamically generated. I'm currently pulling all the possible projects from the DB, and attempting to compare it to the user's input. If it matches, it will be inserted into the DB. Here's what I have so far: //connect to DB here $query="SELECT Task from Tasks where Category='ProjDesc'"; $result = mysql_query($query,$mysql_link); $count="0"; while ($myrow=mysql_fetch_array($result)){ $count= ($count + 1); $idea="$myrow[0]"; $value="project$count"; if ($$value=="$idea") { $compile=$idea; } } $sql=INSERT INTO myprojects (number,date,client,project,projecthours) VALUES ('$number','$date','$client','$compile','$projecthours')"; $result=mysql_query($sql); } The problem is that the $compile only inserts the final project that is selected. I know why this is happening, but I don't know how to correct it. Any ideas? Thanks, -Ben

« previous php.general (#19152) next »