I am trying to insert multiple checkbox values into 1 row. (splink)
And split the inserts into 2 tables (portfolio and splink).
How do i insert these 3 values into splink (table)??
My tables:
portfolio, sections, splink
splink table:
secport_id | client_id | section_id
| |
Portfolio table:
client_id
client
client_cat
Sections table:
section_id
section_name
section_cat
Below is the insert code: (add.php)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form enctype="multipart/form-data" action="add.php" method="POST">
<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#CACACA">
<TR>
<TD colspan="4" bgcolor="#05254B">
<span class="title2">
<b>Add New Client.</b><br>
</span>
</TD>
</TR>
<TR>
<td width="10"><img src="images/trans.gif" width="10" height="5" alt="" border="0"><br></td>
<TD width="80" align="left">
<img src="images/trans.gif" width="80" height="5" alt="" border="0"><br>
<span class="title">
<b>Client:</b> <br>
</span>
</TD>
<TD width="100%">
<img src="images/trans.gif" width="80" height="5" alt="" border="0"><br>
<INPUT TYPE='TEXT' NAME='client' VALUE='' size=34><br>
<img src="images/trans.gif" width="1" height="5" alt="" border="0"><br>
</TD>
<td width="10"><img src="images/trans.gif" width="10" height="5" alt="" border="0"><br></td>
</TR>
<TR>
<td width="10"></td>
<TD align="left">
<span class="title">
<b>Category:</b> <br>
</span>
</TD>
<TD>
<select name="client_cat">
<option value="" SELECTED>Select Category ...</option>
<option value="web">web</option>
<option value="print">print</option>
<option value="motion">motion</option>
</select>
<img src="images/trans.gif" width="1" height="5" alt="" border="0"><br><br>
</TD>
<td width="10"><br></td>
</TR>
<TR>
<td width="10"></td>
<TD align="left" valign="top">
<span class="title">
<b>Sections:</b> <br>
</span>
</TD>
<TD>
<? include 'section-input.php';?>
<img src="images/trans.gif" width="1" height="5" alt="" border="0"><br>
</TD>
<td width="10"><br></td>
</TR>
<TR>
<td width="10"></td>
<TD align="left">
<img src="images/trans.gif" width="1" height="5" alt="" border="0"><br>
<input type="submit" name="submit" value="Submit" /><br>
<img src="images/trans.gif" width="1" height="5" alt="" border="0"><br>
</TD>
</TR>
</TABLE>
</form>
<?
if($_POST['submit']){ //If submit is hit
include ('connect.php');
//convert all the posts to variables:
$client = $_POST['client'];
$client_cat = $_POST['client_cat'];
$result=MYSQL_QUERY("INSERT INTO portfolio (client_id,client,client_cat)".
"VALUES ('NULL', '$client', '$client_cat')");
echo "<br><span class='content'>Information Added.</span><br>
<span class='link'>Go to <a href='admin_home.php' target='_parent'>Admin Home</a></span><br>";
}
?>
<?
/// Get client id \\\
include ('connect.php');
$result = mysql_query("SELECT client_id FROM portfolio ORDER BY client_id DESC LIMIT 1");
while($r=mysql_fetch_array($result)){
$client_id=$r["client_id"];
}
?>
<!-- Insert Multiple checkbox values into splink table with client_id and section_id -->
<? /*
/// PROBLEM AREA \\\
if($_POST['submit']){
include ('connect.php');
//convert all the posts to variables:
$client_id = $_GET['client_id'];
$section_id = $_POST['section_id'];
$result=MYSQL_QUERY("INSERT INTO splink (secport_id,client_id,section_id)".
"VALUES ('NULL', '$client_id',";
for($i = 0; $i <= 1; $i++){
" '$section_name[$i]')";} )
");
echo "<br><span class='content'>Information Added.</span><br>
<span class='link'>Go to <a href='admin_home.php' target='_parent'>Admin Home</a></span><br>";
}*/
?>
<br>
<body>
</html>
How can i do this???