0

hi. am new to php. got a problem with inserting data into another table in mysql database afta.
Here is the code

<td><form action="ProCollegePrograms.php" method="post">
      <table  width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
      <td><span class="textblack">College Code</span><span class="required"><font color="#CC0000">*</font></span><br></td>
      <td><input name="CollegeCode" type="text" class="required username" id="CollegeCode" size="40" minlength="2" ></td>
       <tr>
       </
      </tr>
        <tr>
          <th width="50%" height="39">Check off the programs you offer</th>
          <th width="50%">Course  Name </th>
        </tr>
  <?php
$sql = "SELECT course_no,Name FROM courses ";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);

while($row=mysql_fetch_array($result))
{
$Name=$row['Name'];
?>
     <tr>
<td><input type="checkbox" name="Name[]" value="<?php echo $Name; ?>"  align="middle"/></td>
<td><?php echo $Name; ?>
 <td>&nbsp;</td>
</tr>
<?php

}

?>

Edited by Nick Evan: Fixed formatting

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by TechySafi
0

and the PropCollegePrograms.php is

<?php
include 'admin/dbc.php';

$code=$_POST["CollegeCode"];

if (isset($_POST))
{
foreach ($_POST as $name)
{
//$ints .= "$value, ";
$allnames .= $style . ", ";
$allnames = substr($allnames, 0, -2);
}
else
{
echo 'You forgot to enter a course.';
}

$sql="INSERT INTO procourses ( CollegeCode,Name) VALUES ('code','$allnames')";
$result=mysql_query($sql);
if($result)
{
echo"good";
}
else
{
echo"baaad";
}

?>

0

Try this,

$sql="INSERT INTO procourses ( CollegeCode,Name) VALUES ('$code','$allnames')";

If the problem still remain then explain what kinda error/problem it is! You just said

got a problem with inserting data

but wouldn't it be easier for us to check your code if we would know what problem you are facing?

Apply that code, and let me know the result.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.