Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

69 users online



Multiple checkbox prob

Multiple checkbox prob

Currently viewing this thread: 1 (0 members and 1 guests)


james182

james182

Neverside Newbie
Status: Offline!

Multiple checkbox prob

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)

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">
       &nbsp;<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>&nbsp;<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>&nbsp;<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>&nbsp;<br>
               </span>
           </TD>
        <TD>
            <!-- disciplines -->
            Disciplines: <br>
            <?php 
                
// Database Connection 
                
include 'connect.php'
                
                
$result mysql_query("SELECT * FROM sections WHERE section_cat = 'disciplines'"); 
                
                while(
$r=mysql_fetch_array($result)){
                     
$section_name=$r["section_name"];
                    
$section_img=$r["section_img"];
                    
$section_id=$r["section_id"];
            
?>
                <input type="checkbox" name="section_id" value="<?=$section_id?>"><?=$section_name?><br>
                <?}?>
            <br>
            <!-- components -->
            Components: <br>
            <?php 
                
// Database Connection 
                
include 'connect.php'
                
                
$result mysql_query("SELECT * FROM sections WHERE section_cat = 'components'"); 
                
                while(
$r=mysql_fetch_array($result)){
                     
$section_name=$r["section_name"];
                    
$section_img=$r["section_img"];
                    
$section_id=$r["section_id"];
            
?>
                <input type="checkbox" name="section_id" value="<?=$section_id?>"><?=$section_name?><br>
                <?}?>
            <br>
            <!-- technologies -->
            Technologies: <br>
            <?php 
                
// Database Connection 
                
include 'connect.php'
                
                
$result mysql_query("SELECT * FROM sections WHERE section_cat = 'technologies'"); 
                
                while(
$r=mysql_fetch_array($result)){
                     
$section_name=$r["section_name"];
                    
$section_img=$r["section_img"];
                    
$section_id=$r["section_id"];
            
?>
                <input type="checkbox" name="section_id" value="<?=$section_id?>"><?=$section_name?><br>
                <?}?>
            <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????

mooosh

mooosh

Neverside Newbie
Status: Offline!

The way i'd do it is to get the value of client_id and section_id from the previous row and +1 to those values and add them into splink not the best way to go about it but it should work

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0195 seconds.