Page 1 of 1

checkbox array help

Posted: Mon Dec 18, 2006 1:37 pm
by psurrena
How would I add the value of $check_cat to the array offreq[]?

Code: Select all

<?php
				
		$query = ("SELECT * FROM checkboxes WHERE check_cat='membership_database' ORDER BY id ASC") or die (mysql_error());
		$result = mysql_query($query);
		mysql_query($query) or die (mysql_error() . 'Cannot Retrieve Information');
	
		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
			$id = $row['id'];
			$text = $row['check_text'];
			$check_cat = $row['check_cat']
			
			echo '<tr><td valign="top">';
			echo '<input type="checkbox" name="offreq[]" value="';
			echo str_replace("company_name", $name, $text) . '">';
			echo '</td><td>';
			echo str_replace("company_name", $name, $text);
			echo '</tr>';
		}
	?>

Code: Select all

$offreq = '<li>' . implode('<li>' , $_POST['offreq']);
	$query = "INSERT INTO office_req_final (text) VALUES ('$text)";
	mysql_query($query) or die (mysql_error());

Posted: Mon Dec 18, 2006 1:47 pm
by feyd

Code: Select all

$foo[] = 'bar';

Posted: Mon Dec 18, 2006 2:44 pm
by psurrena
Maybe I should explain more.

There is a table in my database that has all of the checkbox data and each of those has a category.

So I want to create the array with the selected checkboxes (which works) and with each item, associate the category.

In the end, the data is inserted into a table with a field for the checkbox data and a field for the category (same structure as where it came from).

Posted: Mon Dec 18, 2006 7:46 pm
by psurrena
So - I thought it out and here is what needs to be done. Can you pull two items from an arrays, assign them to seperate variables and insert them into your database?

Posted: Mon Dec 18, 2006 11:16 pm
by feyd
As a generality, yes.