- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI'm having a query problem with my SQL. Basically the problem I'm having right now is, I store the cateogry types in the category_type table and then in the static_page_permission table I connect the category_type and the customer_type table together like the following:
insert into static_page_permission VALUES('1', 'customer_type', '2');
Which would link food (from category_type) and Customer (customer_type) to the static_page_permission table.
Let's say for category_type:
1 food YES
2 salad YES
3 fruit YES
4 gardens YES
customer_type:
1 Customer Active
2 Affiliate Active
--
DROP TABLE IF EXISTS `category_types`;
CREATE TABLE `category_types` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(155) NOT NULL default '',
`login` enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `customer_type`;
CREATE TABLE `customer_type` (
`customer_typeid` int(11) NOT NULL auto_increment,
`type_name` varchar(128) NOT NULL default '',
`status` enum('Active','Inactive') NOT NULL default 'Active',
PRIMARY KEY (`customer_typeid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `static_page_permission`;
CREATE TABLE `static_page_permission` (
`typeid` int(11) NOT NULL default '0',
`table_name` varchar(25) NOT NULL default '',
`table_type` int(11) NOT NULL default '0',
KEY `typeid` (`typeid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
Ultimately, I need a way to query this and put it into checkboxes with a way to pass variables to say whether or not it is checked or not. I wrote a funciton that somewhat does that. Please help! If you have an easier way for me to retrieve this, by all means, let me know!
function page_list_customer_types($
{
$output = NULL;
// Sorting
@asort($ids);
$q = mysql_query("select * from customer_type where status='Active'");
for($i = 0; $row = mysql_fetch_assoc($q); ++$i) {
$checked = ($ids[$i] == $row['customer_typeid']) ? "CHECKED" : "";
$output .= "<input ".$checked." type=\"checkbox\" name=\"cust_type_".$i."\" value=\"".$row['customer_t
}
return $output;
}
// $ids is an array of the selected values... but that seems to not be working properly. Please help :)
Jacob
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: CyberGhostPosted on 2006-10-17 at 01:11:13ID: 17745550
Just a guess, but problem might be with that FOR statement.
ypeid']."\ "".((in_ar ray($row[' customer_t ypeid'], $ids)) ? " CHECKED" : "").">".$row['type_name']. "<br />";
Try this:
$pos = 0;
while ($row = @mysql_fetch_assoc($q)) {
$output .= "<input type=\"checkbox\" name=\"cust_types[]\" value=\"".$row['customer_t
}
So when the form gets submitted, you simply run a foreach to update your DB:
foreach ($_REQUEST['cust_types'] as $key) {
// code to update the DB here
// ......................
//
}
regards,
CyberGhost