PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
psurrena
Forum Contributor
Posts: 355 Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY
Post
by psurrena » Mon Dec 18, 2006 1:37 pm
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());
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Dec 18, 2006 1:47 pm
psurrena
Forum Contributor
Posts: 355 Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY
Post
by psurrena » Mon Dec 18, 2006 2:44 pm
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).
psurrena
Forum Contributor
Posts: 355 Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY
Post
by psurrena » Mon Dec 18, 2006 7:46 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Dec 18, 2006 11:16 pm
As a generality, yes.