I have three dropdown boxes. Namely DS, QA, Mod. First step is DS will select a value (YES/NO) & upon submitting, QA will be reviewing the input of DS. I have to get the values of DS Dropdown and display it in the same dropdown box of DS(disabled) when QA is about to check the input.Same goes with Mod.Take note that these dropdown boxes exists in checklist.php file.
<table width="100%" border="1">
<tbody>
<tr>
<td align="left" rowspan="2"><b>Check Items</b></th>
<td><b>DS</b></td>
<td><b>QA</b></td>
<td><b>Mod?</b></td>
</tr>
<tr>
<td align="center" rowspan="2"><select id="valueDS1">
<option value="YD1">YES</option>
<option value ="NAD1">N/A</option>
</select>
</td>
<td align="center" rowspan="2"><select id="valueQA1">
<option value="YQ2">YES</option>
<option value ="NAQ2">N/A</option>
</select>
</td>
<td align="center" rowspan="2"><select id="valueMod1">
<option value="YM1">YES</option>
<option value ="NM1">NO</option>
</select>
</td>
</tr>
<tr>
<td> All extra instructions and corrections applied.</td>
<tr>
<td>
<p> If comments exist, ask DE if they need to be deleted or retained (but hidden)</p>
</td>
<td align="center"><select id="valueDS2">
<option value="Y">YES</option>
<option value ="NA">N/A</option>
</select>
</td>
<td align="center"><select id="valueQA2">
<option value="Y">YES</option>
<option value ="NA">N/A</option>
</select>
</td>
<td align="center"><select id="valueMod2">
<option value="Y">YES</option>
<option value ="NA">NO</option>
</select>
</td>
</tr>
</table>
Inside the PHP code, assign a variable to the dropdown.
$DS= $_POST['DS']
Now, in the HTML of the dropdown do something like following
<select>
<option <?php if(isset($DS) && $DS=="yes" ){ echo "selected"; } ?> value="yes" disabled>Yes</option>
</select>
I am trying to insert multiple rows of data from my form into my sql database. I have been looking up arrays and been trying to apply what I have found but to no avail. I am beginner to programming never took any formal classes, been learning snipits of code as I need, so my fundamentals are nonexistent.
PlayerID is not auto-increment but an actually number provided by the user.
Here is my form code
<table border="1">
<tr>
<td align="center">Form Input Employees Data</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="/wp/wp-content/plugins/FormSubmit/FSdotaArray.php">
<tr>
<td></td>
<td><b>Captain</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<td></td>
<td><b>Player 2</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" name="submit" value="Sent"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
Here is my php code, The header is needed because I am using wordpress and running the code as a plugin.
<?php
/*
Plugin Name: FSdota
Description: submit form data into sql database
Author: F. May
Version: 1.0
*/
//inserting data order
$con=mysqli_connect("XXXXXX","XXXXXXXX","XXXXXXXX","XXXXXXXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysqli_query($con,"XXXXXXXXXX");
$row_data = "($playerid,$firstname, $lastname, $position,$team,$Game)";
if (is_array($row_data));
{
foreach($_POST['playerid'] as $row=>$playerid) {
$playerid = mysqli_real_escape_string('playerid');
$firstname = mysqli_real_escape_string($con,($_POST['firstname'][$row]));
$lastname = mysqli_real_escape_string($con,($_POST['lastname'][$row]));
$position = mysqli_real_escape_string($con,($_POST['position'][$row]));
$team = mysqli_real_escape_string($con,($_POST['team'][$row]));
$game = mysqli_real_escape_string($con,($_POST['game'][$row]));
}
}
if (!empty($row_data)) {
$sql="INSERT INTO wp_es_fstest (PlayerID,FirstName,LastName,Position,Team,Game) VALUES".implode(',', $row_data);
$query = mysqli_query($con, $sql);
if (mysql_query($query))
echo 'Successful inserts: ' . mysql_affected_rows($con);
else
echo 'query failed';
}
?>
You are not sending multiple values for the same fields. Your name attributes are like name="playerid" so that means that every new entry with the same name will overwrite the previous one and only one gets sent to the server.
You should use arrays to group your fields:
<input type="text" name="playerid[SOME_ID]" size="20">
...
<input type="text" name="firstname[SOME_ID]" size="20">
...
// etc.
...
<input type="text" name="playerid[SOME_OTHER_ID]" size="20">
...
<input type="text" name="firstname[SOME_OTHER_ID]" size="20">
...
// etc.
For the SOME_ID, SOME_OTHER_ID, etc. values you could use a value from a database if it already exist or a simple counter, as long as the fields in a group use the same number / ID.
About the php-side, as mentioned by #Fred-ii- you should only use one sql API, in this case mysqli.
Also note that:
$playerid = mysqli_real_escape_string('playerid');
should be:
$playerid = mysqli_real_escape_string($con, 'playerid');
Personally I would also use a prepared statement with bound variables so that you can prepare your statement once and then run it several times with the different groups of values without having to worry about sql injection / escaping the values.
One additional remark:
This is going to fail:
$row_data = "($playerid,$firstname, $lastname, $position,$team,$Game)";
if (is_array($row_data));
{
You have just set your $row_data variable to be a string, probably with a bunch of undefined variables so checking one line after that whether it is an array is never going to work.
Alright so it has been a while since the last point, life got busy and I wanted to do a little more research.
I have modified my form.html to specify that they are arrays and created a new php file to go with it. here is the code below.
<body>
<table border="1">
<tr>
<td align="center">Dota 2 Open Team Registration</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="/wp/wp-content/plugins/FormSubmit/FSdotaArray.php">
<tr>
<td></td>
<td><b>Captain</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[playerid_1]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_1]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_1]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_1]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_1]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_1]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<!-- Player 2 -->
<td></td>
<td><b>Player 2</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[player_2]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_2]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_2]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_2]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_2]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_2]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<!--Player 3 -->
<td></td>
<td><b>Player 3</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[player_3]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_3]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_3]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_3]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_3]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_3]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<!-- Player 4 -->
<td></td>
<td><b>Player 4</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[player_4]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_4]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_4]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_4]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_4]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_4]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<!-- Player 5 -->
<td></td>
<td><b>Player 5</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[player_5]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_5]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_5]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_5]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_5]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_5]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<!-- Player Sub 1 [6] -->
<td></td>
<td><b>Sub 1 (Optional)</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[player_6]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_6]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_6]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_6]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_6]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_6]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<!-- Player Sub 2 [7] -->
<td></td>
<td><b>Sub 2</b></td>
</tr>
<tr>
<td>Steam ID</td>
<td><input type="text" name="playerid[player_7]" size="20">
</td>
</tr>
<tr>
<td>Fisrt Name</td>
<td><input type="text" name="firstname[firstname_7]" size="20">
</td>
</tr>
<tr>
<td>last Name</td>
<td><input type="text" name="lastname[lastname_7]" size="20">
</td>
</tr>
<tr>
<td>Position</td>
<td><select name="position[position_7]">
<option value="1:hardcarry">1: Hard Carry</option>
<option value="2:mid">2: Mid</option>
<option value="3:offlane">3: Offlane</option>
<option value="4:support">4: Support</option>
<option value="5:support">5: Support</option>
</select>
</td>
</tr>
<tr>
<td>Team</td>
<td><input type="text" name="team[team_7]" size="40">
</td>
</tr>
<tr>
<td>Game</td>
<td><select name="game[game_7]">
<option value="dota2">Dota 2</option>
<option value="leagueoflegends">League of Legends</option>
<option value="starcraft2">StarCraft 2: Heart of the Swarm</option>
<option value="USFIV">USFIV</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" name="submit" value="Sent"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
and then the PHP code
<?php
/*
Plugin Name: FSdota
Description: submit form data into sql database
Author: F. May
Version: 1.0
*/
//inserting data order
$con=mysqli_connect("xxxxxxxx","xxxxxxx","xxxxxx!","xxxxx");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
//define values
$player_a = array($playerid_1,$playerid_2,$playerid_3,$playerid_4,$playerid_5,$playerid_6,$playerid_7);
$firstname_a = array($firstname_1,$firstname_2,$firstname_3,$firstname_4,$firstname_5,$firstname_6,$firstname_7);
$lastname_a = array($lastnanme_1,$lastnanme_2,$lastnanme_3,$lastnanme_4,$lastnanme_5,$lastnanme_6,$lastnanme_7);
$position_a = array($position_1,$position_2,$position_3,$position_4,$position_5,$position_6,$position_7);
$team_a = array($team_1,$team_2,$team_3,$team_4,$team_5,$team_6,$team_7);
$game_a = array($game_1,$game_2,$game_3,$game_4,$game_5,$game_6,$game_7);
$playerid = mysqli_real_escape_string($con, '$playerid_a');
$firstname = mysqli_real_escape_string($con, '$firstname_a');
$lastname = mysqli_real_escape_string($con, '$lastname_a');
$position = mysqli_real_escape_string($con,'$position_a');
$team = mysqli_real_escape_string($con, '$team_a');
$game = mysqli_real_escape_string($con, '$game_a');
for ($i = 1; $i < 7; $i++) {
//define arrays into variables with counter
// $a = $playerid_a[$];
// $b = $firstname_a[$i];
// $c = $lastname_a[$i];
// $d = $position_a[$i];
// $e = $team_a[$i];
// $f = $game_a[$i];
$str[ ] = "('{$player_[$i]}','{$firstname_[$i]}','{$lastname_[$i]}','{$position_[$i]}','{$team_[$i]}','{$game_[$i]}')";
}
$s= implode(',', $str);
$sql="INSERT INTO wp_es_fstest (playerid, firstname, lastname, position, team, game) VALUES $s";
echo $sql;
mysqli_close($con);
?>
I dont think I have defined everything correctly, in the echo i am null values.
INSERT INTO wp_es_fstest (playerid, firstname, lastname, position, team, game) VALUES ('','','','','',''),('','','','','',''),('','','','','',''),('','','','','',''),('','','','','',''), ('','','','','','')
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have this form to input data into a MySQL database. It's not giving me any errors, but also not inserting data. I have looked around the web, with no avail. I'm not sure if it's my code or maybe I've misconfigured my database. Here's all the code.
<!DOCTYPE html>
<html>
<head>
<title>Steam Traps Form</title>
<style type="text/css">
table tr > td { text-align: right; }
table tr > td + td { text-align: left; }
</style>
</head>
<body>
<form action="FormHandler.php" method="post" >
<table border="0">
<tr>
<td align="center"><h1>Steam Trap Form Input</h1></td>
</tr>
<tr>
<td>
<tr>
<td>Date of Survey</td>
<td><input type="date" name="dateSurvey">
</td>
<tr>
<tr>
<td>Plant Name</td>
<td><input type="text" name="plantName"></td>
</tr>
<tr>
<td>Plant Location</td>
<td><input type="text" name="plantLoc"></td>
</tr>
<tr>
<td>Plant Contact Name</td>
<td><input type="text" name="plantContact"></td>
</tr>
<tr>
<td>Direction</td>
<td><select name="direction">
<option value="N">N</option>
<option value="NE">NE</option>
<option value="NW">NW</option>
<option value="S">S</option>
<option value="SE">SE</option>
<option value="SW">SW</option>
<option value="E">E</option>
<option value="W">W</option>
</select>
</td>
</tr>
<tr>
<td>Location (detailed as possible)</td>
<td><input type="text" name="location" size="40">
</td>
</tr>
<tr>
<td>Floor Level</td>
<td><select name="flrLevel">
<option value="grd">Ground</option>
<option value="1st">1st</option>
<option value="2nd">2nd</option>
<option value="3rd">3rd</option>
<option value="4th">4th</option>
<option value="5th">5th</option>
<option value="6th">6th</option>
<option value="7th">7th</option>
<option value="8th">8th</option>
<option value="9th">9th</option>
<option value="10th">10th</option>
<option value="11th">11th</option>
<option value="12th">12th</option>
<option value="13th">13th</option>
<option value="14th">14th</option>
<option value="15th">15th</option>
</select>
</td>
</tr>
<tr>
<td>Elevation (in ft)</td>
<td><input type="number" name="elevation" size="5">
</td>
</tr
<tr>
<td>Tag Number</td>
<td><input type="text" name="tagNum" size="20">
</td>
</tr>
<tr>
<td>MFG Model Number</td>
<td><input type="text" name="mmn" size="30">
</td>
</tr>
<tr>
<td>Size</td>
<td><input type="text" name="size" size="10">
</td>
</tr>
<tr>
<td>Pressure</td>
<td><input type="number" name="pressure" size="5">
</td>
</tr>
<tr>
<td>Service</td>
<td><input type="text" name="service" size="5">
</td>
</tr>
<tr>
<td>Trap Conditions</td>
<td><select name="trapCond">
<option value="OK">OK</option>
<option value="BT">BT</option>
<option value="RCL">RCL</option>
<option value="CP">CP</option>
<option value="VO">VO</option>
</select>
</td>
</tr>
<tr>
<td align="right"><input type="submit"
name="submit" value="Submit"></td>
</tr>
</form>
</td>
</tr>
</table>
<br />
</body>
</html>
Here is the PHP
<?php
$dateSurvey = $_POST["dateSurvey"];
$plantName = $_POST["plantName"];
$plantLoc = $_POST["plantLoc"];
$plantContact = $_POST["plantContact"];
$direction = $_POST["direction"];
$location = $_POST["location"];
$flrLevel = $_POST["flrLevel"];
$elevation = $_POST["elevation"];
$tagNumb = $_POST["tagNum"];
$mmn = $_POST["mmn"];
$size = $_POST["size"];
$pressure = $_POST["pressure"];
$service = $_POST["service"];
$trapCond = $_POST["trapCond"];
$sql_connection = mysql_connect("localhost", "******", "******");
mysql_select_db("******", $sql_connection) or die( "Unable to select database");
$sql = "INSERT INTO steamtraps (
dateSurvey,
plantName,
plantLoc,
plantContact,
direction,
location,
flrLevel,
elevation,
tagNum,
mmn,
size,
pressure,
service,
trapCond,
ContactDateCreated,
)
VALUES (
'{$dateSurvey}',
'{$plantName}',
'{$plantLoc}',
'{$plantContact}',
'{$direction}',
'{$location}',
'{$flrLevel}',
'{$elevation}',
'{$tagNum}',
'{$mmn}',
'{$size}',
'{$pressure}',
'{$service}',
'{$trapond}',
NOW()
)";
mysql_query($sql, $sql_connection);
mysql_close($sql_connection);
?>
Try to change the mysql_query to show errors meaningfully:
mysql_query($sql, $sql_connection) or die(mysql_error() . "<br/>Query was: " . $sql);
If you have an error, it will stop execution and you will see both the error and the query that was attempted to be executed.
I'm not sure what version of PHP you are running, but mysql_query and other related commands have been deprecated since PHP-5.5.0. http://php.net/manual/en/function.mysql-query.php
Try using the newer mysqli_query (you will need to update all of your sql commands like mysqli_connect and mysqli_close to match).
http://php.net/manual/en/mysqli.query.php
I am trying to get the value of my input upon a click of the button.
I am able to get the value of text box but not for drop down list and number box (input type=number).
How should I go about doing it?
Below is my code:
<div class=accountMain>
<div align=left>
<table>
<tr>
<td>Product Code:</td>
<td>EX00001</td>
</tr>
<tr>
<td>Product Name:</td>
<td><input type=text name=productName value=$productName></td>
</tr>
<tr>
<td>Description:</td>
<td><input type=text name=productDesc value=$productDesc></td>
</tr>
<tr>
<td>Price: SGD$</td>
<td><input type=text name=unitPrice value=$unitPrice></td>
</tr>
<tr>
<td>Quantity Available:</td>
<td><input type=text name=qty value=$qty></td>
</tr>
<tr>
<td>Size <br>
(Only applicable for T-Shirt):</td>
<td><select>
<option value=N>NIL</option>
<option value=S>S</option>
<option value=M>M</option>
<option value=L>L</option>
<option value=XL>XL</option>
</select></td>
</tr>
<tr>
<td>Product Image:</td>
<td><input type=file name=imgfile></td>
</tr>
<tr>
<td>Category: Exclusive</td>
</tr>
<tr>
<td></td>
<td><input type=submit name=insert value=Insert></td>
</tr>
</table>
</div>
</td>
</tr>
</div>
echo("<tr><td></td>
<td></td>
<td><font style=title><b>In Stock : ".$row["qty"]."</b></br></br></br></br>
<b><form>Purchase Qty : <input type=number name=qty min=1 max=5></form></b></br></br>
</br></font></td>
</tr>");
echo("<tr><td></td>
<td></td>
<td><a href=shoppingbag.php><img src=images/addToCartBtn.png width=150></a></td></tr>");
your <select> requires a name attribute
Change the following:
<select>
<option value=N>NIL</option>
<option value=S>S</option>
<option value=M>M</option>
<option value=L>L</option>
<option value=XL>XL</option>
</select>
To:
<select name="size">
<option value=N>NIL</option>
<option value=S>S</option>
<option value=M>M</option>
<option value=L>L</option>
<option value=XL>XL</option>
</select>
And get it using:
<?php $_POST["size"]; ?>
Since this is also marked under PHP, I presume you want to send these values to a PHP page?
If so, unless you are submitting the values dynamically (through script), you'll want to wrap the input and select elements in <form> opening and closing tags. Then you can set the method attribute (post,put,get,delete) and the action attribute (the path to the PHP page to process the values).
<form method="post" action="path-to/my-php-page.php">
...
</form>
HINT: The way your HTML is structured, you may want to wrap the whole of the innermost table with the form tag.