print <<<HERE
<form name="form1" method="post" action="">
<table width="100%" border="0">
<tr>
<td align="left" valign="top"><label>Topic
<input name="msg_subject" type="text" id="msg_subject" size="55" maxlength="35">
</label></td>
</tr>
<tr>
<td align="left" valign="top"><label>
<textarea name="msg_message" id="msg_message" cols="60" rows="5"></textarea> <input name="id" type="hidden" id="id" />
</label></td>
</tr>
<tr>
<td align="left" valign="top">
HERE;
?>
<?php
$s = " ";
$sql_list = mysql_query("SELECT * from bbcal_userlist ORDER BY firstname ASC");
$if_exist = mysql_num_rows($sql_list);
while($m_res = mysql_fetch_array($sql_list)){
?>
<label>
<input name="names" type="checkbox" value ="<?php echo $m_res . $s . $m_res; ?>" />
<?php echo $m_res . $s . $m_res; ?></label>
<br />
<?php
}
?>
<?php
print <<<HERE
</td>
</tr>
<tr>
<td align="left" valign="top"><label>
<input type="submit" name="submit" id="submit" value="Create a topic">
</label></td>
</tr>
</table>
</form>
HERE;
So I have a checkboxes running from database, And lets see i have:
$_POST
$_POST
$_POST
f (isset($_POST)) {$msg_message = $_POST;}
if (isset($_POST)) {$msg_subject = $_POST;}
if (isset($_POST)) {$namest = $_POST;}
So I need to do something like: FOREACH $names
{
mysql_query("INSERT INTO tablename (subject, name) VALUES ($msg_subject, $names)");
}
So basicaly there are going to be insert into two different tables. 1st table will contain the subject, message, id. The second table should contain the same id as the first table, and new row for each subsribtion.
EXAMPLE
1st table
ID: "5761" SUBJ: "Hello world" MSG: "here is a message"
2 nd table
S_ID: "5761" NAME: "username1"
S_ID: "5761" NAME: "username2"
S_ID: "5761" NAME: "username3"
S_ID: "5761" NAME: "username4"
S_ID: "5761" NAME: "username5"
If you can see each record for the second table should have the same ID and new row for each checked checkbox.
The first table is running okay, I just need to insert a new row for the second table.... Reply if you can do that... or if there is another way of doing that...
I just saw a similar topic about it, but I am pretty new to php. Any help would be appreciated