Forum Moderators: coopster
id¦option1¦option2¦option3¦option4
1¦this¦that¦theother¦thensome
2¦that¦this¦theother¦thensome
3¦thensome¦theother¦that¦this
4¦this¦¦¦
5¦that¦¦¦
I would need to call these like this:
All
Only that
Only this
Only theother
Only thensome
Calling them is not a major issue. I need to figure out how to add them to the database, I do not want it to add "that" twice and I am not sure how to check to see if it needs to go into option1-4 ei: if option1 is already taken put in option2.
Any ideas on this?
use checkboxes, one for each option
then have three tables:
users (userid, name, etc etc etc )
options (optionid, optiontext)
subscriptions (userid, optionid)
users has the user data, with a unique userid
options is the list of possible options, each with unique id
subscriptions will have up to 4 entries per user :-) showing the user'sid and the option'sid
then you can query for a user's info:
WHERE users.userid=options.userid
or for subscribers to an option:
WHERE options.optionid=3
:D
how's that sound?
---------for the form
$sql="SELECT optionid,optiontext FROM options WHERE 1 ORDER BY optiontext asc";
$dh=mysql_query($sql);
while ($r=mysql_fetch_row($dh))
{
echo "<span style=\"width: 48%; font-size: 12px;\"><INPUT TYPE=\"checkbox\" NAME=\"$r[0]\">$r[ 1]</span>";
}
-----------for the inserting (requires $userid to be set)
$sql="SELECT optionid FROM options WHERE 1 ORDER BY optiontext asc";
$dh=mysql_query($sql);
while ($r=mysql_fetch_row($dh))
{
if ($_REQUEST[$r[0]]) mysql_query("INSERT INTO subscriptions (userid, optionid) VALUES ($userid, $r[0]);");
}
Any help?
<edited to correct code>... help still buggy! where i put $r[ 1] above - take out that space... WW code is messing up
[edited by: vincevincevince at 4:22 pm (utc) on June 29, 2003]