Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database entry loop - EXTREMELY URGENT 1

Status
Not open for further replies.

overyde

Programmer
May 27, 2003
226
ZA
hi,
I have a deadline for monday and am stuck with this:

i have numerous data from a loop that only needs to go into 1 blolb field and comma seperated. I can get each bit of info in it's own row, or just the last entry but i can not get them all into the same field!
my code is as follows:
Code:
<?php

session_start();
// open the connection
$conn = mysql_connect("localhost", "", "");

// pick the database to use
mysql_select_db("test",$conn);


if (!empty($_POST[question])) {
	foreach ($_POST[question] as $value) {
		if ($value == "") {
			print "<li>field is empty,please go back and fill in the required fields that are missing<br>
			<a href=\"javascript:history.back()\"> return to form</a>";
			exit;
		}else{
			print "$value,";



	
}
$sql = "INSERT INTO test_tab (f2) VALUES ('$value')";	

	}
	if (mysql_query($sql, $conn)) {
	echo " <br>entered";
}else{
	echo "nah";
}

}
?>

please help!!!

Reality is built on a foundation of dreams.
 
Don't worry!
Sorted, thanks!

Reality is built on a foundation of dreams.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top