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!
The above code does will only insert $data but not $data_b. The arrays are from checkboxes, which work, and it's very importtant the category is correct for each one. $data must have 'office_requirements' in the same row.
psurrena wrote:Thanks! I really like how it works with the functions - very clean.
One question, why does it not work with c_id but will with cid?
You need to see what your field and variables are called and name them appropriately. There is a difference between c_id and cid just like there is a difference between 'pancake' and 'syrup'.
Your first set of names where it says....INSERT INTO checkboxes_final (c_id, check_text, check_cat) --> these are the field names in the table 'checkboxes_final' in your database
VALUES ('$c_id','$data_b', 'membership_database') -->These are all of your variable names that you are getting from php
function viewservices($category){
$query = "SELECT * FROM checkboxes_final WHERE cid='$cid' AND check_cat='$category'";
$result = mysql_query($query);
mysql_query($query) or die (mysql_error());
}
function viewservices($category){
$query = "SELECT * FROM checkboxes_final WHERE cid='$cid' AND check_cat='$category'";
return mysql_query($query);
}
$result = viewservices("office_requirements");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$check_text = $row['check_text'];
echo $check_text;
}
Should work. Enjoy. Also, you should take a look at mysql_real_ecape_string(). At minimum, any data coming from the user should be passed through this function to avoid sql injection.
look at it carefully.. which variable are you returning? Also, are you only expecting a single row? If so you might want to add LIMIT 1 on your query.. just in case.
This project is set up like so:
100 check boxes in 5 or so categories. The user checks which ones they want to appear in the final document under the approriate category via seperate queries. In