Saving data from a checkbox using PHP and MySQL - php

Here is my code:
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$description = $row['description'];
$picturepath = $row['picturepath'];
$name = $row['name'];
$price = $row['price'];
$keywords = $row['keywords'];
$dynamiclist = '<table align="center" width="60%" border="0" cellspacing="5" cellpadding="8">
<tr height="20"></tr>
<tr>
<td width="70%" valign="top" align="left"> <br />' . $name . ' <br /><br />$' . $price . '<br /><br />
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value=" ' . $name . ' - $' . $price . ' - "checkbox"/>';
echo $dynamiclist;
foreach(explode(',', $keywords) as $keyword) {
$keyword = trim($keyword);
echo "<input type='checkbox' name='checkbox' value='$keyword'>$keyword <br /><br />";
}
echo '<input type="submit" name="button" id="button" value="Add to Order"/> </form> </td></tr></table>';
}
mysqli_close($con); //close the db connection
The code pulls in an item using the items id, and then creates checkboxes and keywords for that item. A user is to click on the checkbox options they want and then submit the form which sends the information to the shopping cart. The problem is that when the form is submitted, only the name and price of the item is sent over, but not the checkbox options that were clicked. Can you help me identify why? Side note. In my database I have a column "keywords" where multiple keywords are stored. // medium, well, rare, milk, apple juice, fries. Also, on the cart.php the I have:
if(isset($_POST['pid'])){
$pid = $_POST['pid'];
which posts the data from the script using the checkboxes. I'm just stuck and can't get any further.

You should have different name for your checkbox:
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$description = $row['description'];
$picturepath = $row['picturepath'];
$name = $row['name'];
$price = $row['price'];
$keywords = $row['keywords'];
$dynamiclist = '<table align="center" width="60%" border="0" cellspacing="5" cellpadding="8">
<tr height="20"></tr>
<tr>
<td width="70%" valign="top" align="left"> <br />' . $name . ' <br /><br />$' . $price . '<br /><br />
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value=" ' . $name . ' - $' . $price . ' - "checkbox"/>';
echo $dynamiclist;
$i=0;
foreach(explode(',', $keywords) as $keyword) {
$keyword = trim($keyword);
$chkname = "checkbox{$i}";
$i = $i+1;
echo "<input type='checkbox' name='$chkname' value='$keyword'>$keyword <br /><br />";
}
echo '<input type="submit" name="button" id="button" value="Add to Order"/> </form> </td></tr></table>';
}
mysqli_close($con); //close the db connection
You need to get checkbox data in the cart.php like this:
if($_REQUEST['checkbox0']) echo $_REQUEST['checkbox0'];
if($_REQUEST['checkbox1']) echo $_REQUEST['checkbox1'];
//so on foreach checkbox

Your checkboxes need to have different names, otherwise the values are overwritten:
<input type="checkbox" name="keyword1" value="keyword1">Keyword1
<input type="checkbox" name="keyword2" value="keyword2">Keyword2
<input type="checkbox" name="keyword3" value="keyword3">Keyword3
You then access them in PHP like so:
if ( isset($_GET['keyword1']) ) {
}
if ( isset($_GET['keyword2']) ) {
}
if ( isset($_GET['keyword3']) ) {
}
A more logical way to manage the data is to pass the checkbox values as an array:
<input type="checkbox" name="keyword[]" value="keyword1">Keyword1
<input type="checkbox" name="keyword[]" value="keyword2">Keyword2
<input type="checkbox" name="keyword[]" value="keyword3">Keyword3
It then becomes much easier to work with the data in PHP;
if ( isset($_GET['keyword']) && is_array($_GET['keyword']) ) {
foreach ( $_GET['keyword'] as $v ) {
}
}

Related

gathering all info from database

I created a database for my wifes jewelry site. When i tried to gather the information from the database for the product page I only was able to get the last item I had put inside the database. I originally got the code from a tutorial and had to work on it in order to get any items at all. Basically I need to access all the product but I only get one. Can someone show me what I am missing?
The code to bring up the items:
$id = '';
if( isset( $_GET['id'])) {
$id = $_GET['id'];
}
$sql = "SELECT * FROM products WHERE category = 'Accessories'";
$result = mysqli_query($con, $sql);
$resultCheck = mysqli_num_rows($result);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $item_number = $row["item_number"];
$price = $row["price"];
$desc = $row["description"];
$category = $row["category"];
}
}
This is the code for the table:
<table width="100%" border="2" cellspacing="0" cellpadding="15">
<tr>
<td width="19%" valign="top"><img src="pictures/inventory/<?php echo $pid; ?>.jpg" width="142" height="188" alt="<?php echo $item_number; ?>" /><br />
View Full Size Image
</td>
<td width="81%" valign="top">
<h3 class="Item"><?php echo $item_number; ?></h3>
<p>
<?php echo "$".$price; ?>
<br />
<br />
<?php echo $desc; ?>
<br />
</p>
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value="<?php echo $pid; ?>" />
<input class="button" type="submit" name="button" id="button" value="Add to Shopping Cart" />
</form>
</td>
</tr>
</table>
Basic Solution:
try to assign the data to arrays instead of variables like that:
while($row = $result->fetch_assoc()) {
$item_number[] = $row["item_number"];
$price[] = $row["price"];
$desc[] = $row["description"];
$category[] = $row["category"];
}
and then use a for to display your HTML table like that:
<?php
for ($i=0; $i <sizeof($item_number) ; $i++) {
?>
<table width="100%" border="2" cellspacing="0" cellpadding="15">
<tr>
<td width="19%" valign="top"><img src="pictures/inventory/<?php echo $item_number[$i]; ?>.jpg" width="142" height="188" alt="<?php echo $item_number[$i]; ?>" /><br />
View Full Size Image</td>
<td width="81%" valign="top"><h3 class="Item"><?php echo $item_number[$i]; ?></h3>
<p><?php echo "$".$price[$i]; ?><br />
<br />
<?php echo $desc[$i]; ?>
<br />
</p>
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value="<?php echo $item_number[$i]; ?>" />
<input class="button" type="submit" name="button" id="button" value="Add to Shopping Cart" />
</form>
</td>
</tr>
</table>
<?php
}
?>
I replaced your $pid with $item_number[$i].
Assuming you are trying to show all items. You could use a function to generate the html for all the items and outside the function declare a variable containing all the html. You can then echo that anywhere in the page.
<?php
function generateTableHtml() {
$tableHtml = '<table width="100%" border="2" cellspacing="0" cellpadding="15">';
while($row = $result->fetch_assoc()) {
$tableHtml .= '<tr>';
$tableHtml .= '<td width="19%" valign="top">';
$tableHtml .= '<img src="pictures/inventory/' . $row['item_number'] . '.jpg" width="142" height="188" alt="' . $row['item_number'] . '" /><br />';
$tableHtml .= 'View Full Size Image</td>';
$tableHtml .= '<td width="81%" valign="top"><h3 class="Item">' . $row['item_number'] . '</h3>';
$tableHtml .= '<p>' . $row['price'] . '<br/><br/>';
$tableHtml .= $row['description'];
$tableHtml .= '<br />';
$tableHtml .= '</p>';
$tableHtml .= '<form id="form1" name="form1" method="post" action="cart.php">';
$tableHtml .= '<input type="hidden" name="pid" id="pid" value="'. $pid . '" />'
$tableHtml .= '<input class="button" type="submit" name="button" id="button" value="Add to Shopping Cart" />';
$tableHtml .= '</form>';
$tableHtml .= '</td>';
$tableHtml .= '</tr>';
}
$tableHtml .= '<table>';
return $tableHtml;
}
$tableHtml = generateTableHtml();
?>
<!-- the rest of your html -->
<?php echo $tableHtml; ?>

HTML PHP check box

How can I style my code so that the check box can be aligned beside the table.
All of the check boxes are appearing above the table, but not beside it.
Consider the following snippet of code as well as the picture attached at the end.
<html>
<head>
<title> Furni checker </title>
</head>
<body>
<h1>Furniture Lookup / Furniture Checker</h1> <br />
<br /><p>This tool is used for removal or check furniture on a user account.</p> <br />
<h2> Instructions : </h2> <br />
<p> Lookup User ID and Lookup for the Furniture! </p>
<?php
require_once "global.php";
echo '<h1>Furniture Lookup / Furniture Checker</h1>
<br /><p>This tool is used for removal or check furniture on a user account.</p>';
echo '<br />
<form method="post">
Username:
<input type="text" name="user">
<input type="submit" value="Lookup">
</form>';
if (isset($_POST['user'])) {
$user = filter($_POST['user']);
$getUser = dbquery("SELECT * FROM users WHERE users.username = '" . $user . "' ");
while($show1 = mysql_fetch_array($getUser)) {
echo ''. $show1['id']. '';
}
}
?>
<br />
<?php
echo '
<form method="post">
ID:
<input type="text" name="id">
<input type="submit" value="Lookup">
</form>';
if (isset($_POST['id'])) {
$id = filter($_POST['id']);
$getFurniture = dbquery("SELECT public_name FROM furniture JOIN items ON items.base_item = furniture.id WHERE items.user_id = '" . $id . "' ORDER BY public_name ASC ");
echo '<table border=1 cellpadding=1 width="10%">';
while($show = mysql_fetch_array($getFurniture)) {
//echo ''. $show['public_name'].'' ;
echo '<tr class="t_row">';
echo '<input type="checkbox"> <td>' .$show['public_name']. '</td>';
echo '</tr>';
}
echo '</input>';
echo '</table>';
}
?>
Image:
Try this:
<?php
if (isset($_POST['submit']))
{
$id = filter($_POST['id']);
$getFurniture = dbquery("SELECT public_name FROM furniture JOIN items ON items.base_item = furniture.id WHERE items.user_id = '" . $id . "' ORDER BY public_name ASC ");
echo '<table border=1 cellpadding=1 width="10%">';
while($show = mysql_fetch_array($getFurniture)){
//echo ''. $show['public_name'].'' ;
echo '<tr class="t_row">';
echo '<td>' .$show['public_name']. '</td><td><input type="checkbox" /> </td>';
echo '</tr>';
}
echo '</table>';
}
?>
Let me know if it's not working.

php update dynamic sql rows through form

My goal is to retrieve a dynamic SQL list of rows and edit every item in the list within the same page using POST (no multiple changes at once required). Can this be achieved within the same page? I made the script below which displays everything the way i want to, however the switch statement doesn't seem to be fit for purpouse.
I am aware this code might not be best practice (not to mention secure). Sorry for being inflexible, but i'm not allowed to use anything other then PHP/HTML
Code:
<?php
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<tr> <td class="tg">' .$row["id"]. '</td>' . "\n";
echo '<td class="tg"> <form action= "" method="post"> <input type="text" name="voornaam" value="'.$row["voornaam"].'" style="width:100px"> <input name="submit" type ="submit" value="Aanpassen"><br/><br/>' . '</td>' . "\n";
echo '<td class="tg"> <form action= "" method="post"> <input type="text" name="voornaam" value="'.$row["achternaam"].'" style="width:100px"> <input name="submit" type ="submit" value="Aanpassen"><br/><br/>' . '</td>' . "\n";
echo '<td class="tg"> <form action= "" method="post"> <input type="text" name="voornaam" value="'.$row["omschrijving"].'" style="width:500px"> <input name="submit" type ="submit" value="Aanpassen"><br/><br/>' . '</td> </tr>' . "\n";
}
} else {
echo "0 resultaten";
}
switch(!empty($_POST))
{
case !empty($_POST[$row["voornaam"]]):
// update SQL query 'firstname' here
break;
}
$conn->close();
?>
By this way you actualy see what you are editing and it's more clean.
// PDO DB conecction (secure way)
try {
$con = new PDO("mysql:host={$host};dbname={$db_name}", $username, $password);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $exception){ //to handle connection error
echo "Connection error: " . $exception->getMessage();
}
if isset($_POST["voornaam"]){
$stmt = $con->prepare(" QUERY");
$stmt->execute();
echo "YEAH you did it";
} else {
stmt = $con->prepare(" QUERY");
$stmt->execute();
$rows = $stmt->fetchAll();
foreach ($rows as $rs)
{
$voornaam = $rs["voornaam"]
$achternaam = $rs["achternaam"]
$omschrijving = $rs["omschrijving"]
}
}
// Just an example
echo '<form action= "" method="post"> <input type="text" name="voornaam" value="'. $voornaam .'" style="width:100px"><input name="submit" type ="submit" value="Submit"><br/><br/>';
Value is also the input so you can have only one Submit button at the end cause all other data will be overwritten by itself.
<?php
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
echo '<tr> <td class="tg">' .$row["id"]. '</td>' . "\n";
echo '<td class="tg"> <form action= "" method="post"> <input type="text" name="voornaam" value="'.$row["voornaam"].'" style="width:100px"> <input name="submit" type ="submit" value="Aanpassen"><br/><br/>' . '</td>' . "\n";
echo '<td class="tg"> <form action= "" method="post"> <input type="text" name="voornaam" value="'.$row["achternaam"].'" style="width:100px"> <input name="submit" type ="submit" value="Aanpassen"><br/><br/>' . '</td>' . "\n";
echo '<td class="tg"> <form action= "" method="post"> <input type="text" name="voornaam" value="'.$row["omschrijving"].'" style="width:500px"> <input name="submit" type ="submit" value="Aanpassen"><br/><br/>' . '</td> </tr>' . "\n";
}
}
else
{
echo "0 resultaten";
}
if( isset( $_POST[$row["voornaam"]] ) && !empty( $_POST[$row["voornaam"]] ) )
{
// update SQL query 'firstname' here
}
$conn->close();
?>
In your switch you're sending !empty($_POST) so boolean (true or false) so unique cases would be: True or False...
It's better if you change your switch to:
if(isset($_POST[$row["voornaam"]]) && !empty($_POST[$row["voornaam"]])){
// update SQL query 'firstname' here
}

Create checkboxes in php that correspond to MySQL data

I have a php script that pulls information out from my database.
$result = mysqli_query($con,"SELECT * FROM menuitem WHERE id='$id' LIMIT 1");
if (!$result) {
printf("Error: %s\n", mysqli_error($con));// Displays the error that mysql will generate if syntax is not correct.
exit();
}
//DYNAMIC PHP PULLING IN THE DATA AND SPITTING OUT THE RESULTS
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$description = $row['description'];
$picturepath = $row['picturepath'];
$name = $row['name'];
$price = $row['price'];
$keywords = $row['keywords'];
$dynamiclist = '<table align="center" width="60%" border="0" cellspacing="5" cellpadding="8">
<tr height="150"></tr>
<tr>
<td width="30% valign="top" align="center"><img style="border: #66cc33 5px solid;" src=" ' .$picturepath . '" height="200" width="200" border="1"/></td>
<td width="70%" valign="top" align="left"> <br />' . $name . ' <br /><br />$' . $price . '<br /><br /><font>Description:</font><br /> ' . $description . ' <br /><br /><br />
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="keywords" id="keywords" value=" '. $keywords .'"/>
<input type="hidden" name="pid" id="pid" value=" ' . $name . ' - $' . $price . ' "/>
<input type="submit" name="button" id="button" value="Add to Order"/>
</form>
</td>
</tr>
<tr align="center"><td>View Your Order</td></tr>
</table>';
echo $dynamiclist;
}
mysqli_close($con); //close the db connection
?>
And then I have another page where I want checkboxes created for each keyword listed. I'm not sure if I have my db colum set up correctly, but I have a column set up with multiple keywords: first, second, fifty, none, and more.
I've tried creating this, but it only displays actual "checkboxes" with no text next to any of them.
<?php
require("database.php"); //connect to the database
if(isset($_POST['keywords'])){
$pid = $_POST['keywords'];
}
$result = mysqli_query($con,"SELECT * FROM menuitem ");
if (!$result) {
printf("Error: %s\n", mysqli_error($con));// Displays the error that mysql will generate if syntax is not correct.
exit();
}
//DYNAMIC PHP PULLING IN THE DATA AND SPITTING OUT THE RESULTS
$option = '';
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
$description = $row['description'];
$picturepath = $row['picturepath'];
$name = $row['name'];
$price = $row['price'];
$keywords = $row['keywords'];
$dynamiclist ="<input type='checkbox' name='checkbox' value='". $keywords ."'>";
echo $dynamiclist;
}
The goal is to have a user select an item from the first page, and on the second page, list several checkbox options for that specific item. Any help would be greatly appreciated.
If you want text next to the checkbox, you have to put it in the HTML. And if the column contains a comma-separated list, you need to split it up.
foreach(explode(',', $keywords) as $keyword) {
$keyword = trim($keyword);
echo "<input type='checkbox' name='checkbox' value='$keyword'>$keyword ";
}
Try this:
<?php
$keywords = explode(',', $keywords);
if(!empty($keywords))
{
foreach($keywords as $keyword) {
$keyword = trim($keyword);
echo "<input type='checkbox' name='checkbox' value='$keyword'>$keyword ";
}
}
?>
Thanks!

How to use arrays for form input and update respective database records

I'm new to PHP... I want to know how to populate a form from mySQL. I'm stumped at the input section where I am trying to allow the user to select choices for radio button /checkbox for each record. thanks in advance for anyone's help!
TC
Here's a snippet of my code:
<?php
$mQuantity = 1;
$con = mysql_connect("localhost","t","c");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tc", $con);
/*
if request.form("itemname")<>" " then
cSQLAcct = "SELECT * FROM Restaurant_Menus WHERE Restaurant_ID='" & mRestaurant_ID & "' and Item like '%" & Request.Form("ITEMNAME") & "%' ORDER BY FOODTYPE, ITEM"
else
cSQLAcct = "SELECT * FROM Restaurant_Menus WHERE Restaurant_ID='" & mRestaurant_ID & "' ORDER BY FOODTYPE, ITEM"
end if
*/
// retrieve form data
$input = $_POST['itemname'];
echo $_POST['ITEM'];
$mItem = $_POST['ITEM'];
$mPrice = $_POST['PRICE'];
$mQuantity = $_POST['QUANTITY'];
$mOrderTotal = 0;
$mSide0 = '1';
$mOil = '1';
$mStarch = '1';
$mSalt = '1';
// use it
echo "You searched for: <i>$input</i>";
echo $mSessionID;
mysql_query("INSERT INTO OrderQueue (SessionID,item,quantity,price,no_oil,no_starch,no_salt,side0) VALUES ('$mSessionID','$mItem','$mQuantity','$mPrice','$mOil','$mStarch','$mSalt','$mSide0')");
/*
$sql="SELECT * FROM Restaurant_Menus
WHERE
Item like '%$input%'";
*/
$sql="SELECT * FROM OrderQueue
WHERE
SessionID = '$mSessionID'";
$result = mysql_query($sql);
//('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
//echo $input;
//echo $sql;
/*
if ($input!=" "){
$result = mysql_query($sql);
}
// cSQLAcct = "SELECT * FROM Restaurant_Menus WHERE Restaurant_ID='" & mRestaurant_ID & "' and Item like '%" & Request.Form("ITEMNAME") & "%' ORDER BY
else
{ $result = mysql_query("SELECT * FROM Restaurant_Menus");
}
*/
$c=1;
$class[1] = 'odd';
$class[2] = '';
$array_no_oil = array();
$array_no_salt = array();
$array_no_starch = array();
$array_rice = array();
echo "<table border='1' width=500px>
<tr>
<th></th>
<th align=left>Item</th>
<th align=right>Price</th>
<th align=right>Quantity</th>
</tr>";
//<tr onMouseOver="this.bgColor = '#F3EB49'" onMouseOut ="this.bgColor = '#DDDDDD'" bgcolor="#DDDDDD">
while($row = mysql_fetch_array($result))
{
//echo '<tr class="'.$class[$c].'" onMouseOver='#F3EB49' onMouseOut ='#DDDDDD' bgcolor="#DDDDDD" >';
//echo "<tr class='odd'>";
//echo '<tr onMouseOver="this.bgColor = '#F3EB49'" onMouseOut ="this.bgColor = '#DDDDDD'" bgcolor="#DDDDDD">'
?>
<TR onMouseover="this.bgColor='#FFC000'"onMouseout="this.bgColor='#DDDDDD'">
<?php
/*
<form action="Orders.asp" method="post" target="_top" name="LogonForm">
<td><font size = 2>
<!--<%= mQuantity %>-->
<INPUT TYPE="TEXT" NAME="QUAN" VALUE="1" SIZE=2>
</font></td>
<td width=50px><font size = 2>
<INPUT TYPE=HIDDEN NAME=ITEM VALUE="<% =mItem %>">
<INPUT TYPE=HIDDEN NAME=PRICE VALUE=<% =mPrice %>>
<INPUT TYPE=HIDDEN NAME=RID VALUE= <% =mRestaurant_ID %>>
<INPUT TYPE=HIDDEN NAME=ADDITEM VALUE = "1">
<input id="Choices" class="findit" type="submit" value ="Order" />
</form>
*/
?>
<?php
// Obtain list of images from directory
//$img = getRandomFromArray($imgList);
}
?>
<?php
if ($row['Picture']!=" "){
echo "<td><a><img src='images/".$row['Picture'].".JPG' height=50px></a></td>";
}
else{
echo "<td></td>";
}
echo "<td width=200><b>" . $row['Item'] . "</b><br>
<input class='dropwidth' type='radio' name='$array_rice' value='1' selected>White Rice<br>
<input type='radio' name='$array_rice' value='2'>Pork Fried Rice<br>
<input type='radio' name='$array_rice' value='3'>Brown Rice<br>
<input type='checkbox' name='$array_no_oil' value='1' />No Oil
<input type='checkbox' name='starch' value='no oil' />No Starch
<input type='checkbox' name='salt' value='no salt' />No Salt
</td>";
echo "<td width=50 align=right>" . number_format($row['Price'],2) . "</td>";
$mQuantity = "'" . number_format($row['Quantity'],0) . "'";
$mPrice = "'" . number_format($row['Price'],2) . "'";
$mLineItemTotal = $row['Quantity'] * $row['Price'];
$mOrderTotal = (number_format($mOrderTotal,2) + number_format($mLineItemTotal,2));
echo $mOrderTotal;
$mLineItemTotal2 = "'". number_format($mLineItemTotal,2) . "'";
//echo "<td>" . $mQuantity. "</td>";
?>
<form action="orders.php" method="post" target="_top" name="LogonForm">
<td width="50" align=right><font size = 2>
<!--<%= mQuantity %>-->
<!--<INPUT TYPE="TEXT" NAME="QUANTITY" VALUE=<?php $mQuantity; ?>>-->
<INPUT TYPE="TEXT" NAME="QUANTITY" VALUE=<?php echo $mQuantity.";" ?>/>
</font></td>
<?php echo "<td width=50 align=right>" . $mLineItemTotal . "</td>";?>
<!--<td width=50px><font size = 2>-->
<!--<INPUT TYPE="TEXT" NAME="LINEITEMTOTAL" VALUE=<?php echo $mLineItemTotal.";" ?> WIDTH=10/>-->
<INPUT TYPE=HIDDEN NAME=ITEM VALUE=<?php $mItem ?> />
<INPUT TYPE=HIDDEN NAME=PRICE VALUE=<?php $mPrice ?>/>
<INPUT TYPE=HIDDEN NAME=RID VALUE=<?php $mRestaurant_ID ?>/>
<INPUT TYPE=HIDDEN NAME=ADDITEM VALUE = "1">
<!--<input id="Choices" class="findit" type="submit" value ="Order" />-->
</form>
<?php
echo "</tr>";
if($c==2) $c=0;
$c++;
}
echo "</table>";
echo "<div>".$mOrderTotal."</div>";
mysql_close($con);
?>
You should name your HTML form elements as such: MyElement[] when using them as arrays. For example:
<form method="post" name="myForm" action="myForm.php">
<select multiple name="myFormSelectMultiple[]">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</form>
In this select multiple example, when the first two items are selected and then posted this form would produce similar output to the following:
array('myFormSelectMultiple' => array(1,2));
Hope this helps!

Categories