I have a form for tracking an investment's performance.
The code looks like this:
<form style="margin-top: 60px" action="" method="post">
<p>
<table>
<tr>
<th>Name of Investment</th>
</tr>
<tr>
<td><select name="">
<?php
$sql = 'SELECT DISTINCT deal_name FROM tbl_deal';
$result = mysqli_query($DBconnect, $sql);
if(mysqli_num_rows($result) > 0)
{
echo "<option value=''>Select Investment</option>";
while($row = mysqli_fetch_array($result))
{
echo "<option value='$row[0]'>$row[0]</option>";
}
}
else
{
echo "<option value=''>No Investments Found</option>";
}
?>
</select></td>
</tr>
</table>
<p>
<table>
<tr>
<th></th>
<th colspan="2">Year 1</th>
<th colspan="2">Year 2</th>
<th colspan="2">Year 3</th>
<th colspan="2">Year 4</th>
<th colspan="2">Year 5</th>
</tr>
<tr>
<th>Month</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
</tr>
<tr>
<th>January</th>
<td>
<select name="">
<option value="">Distribution Received</option>
<option value="">Return of Capital</option>
<option value="">Capital Call</option>
</select>
</td>
<td><input type="text" name="" size="5"></td>
<td>
<select name="">
<option value="">Distribution Received</option>
<option value="">Return of Capital</option>
<option value="">Capital Call</option>
</select>
</td>
<td><input type="text" name="" size="5"></td>
<td>
<select name="">
<option value="">Distribution Received</option>
<option value="">Return of Capital</option>
<option value="">Capital Call</option>
</select>
</td>
<td><input type="text" name="" size="5"></td>
<td>
<select name="">
<option value="">Distribution Received</option>
<option value="">Return of Capital</option>
<option value="">Capital Call</option>
</select>
</td>
<td><input type="text" name="" size="5"></td>
<td>
<select name="">
<option value="">Distribution Received</option>
<option value="">Return of Capital</option>
<option value="">Capital Call</option>
</select>
</td>
<td><input type="text" name="" size="5"></td>
</tr>
...and so on for everything month. As you can see, it's very repetitive. I tried making a PHP function to at least minimize the dropdown menu's redundancy, but I get an 'unexpected <' error.
It seems that the HTML tags are giving me problems?
Any advice how to write PHP functions containing HTML?
Any other advice on minimizing the redundancy?
The new and concise code:
<?php
echo '
<table>
<tr>
<th></th>
<th colspan="2">Year 1</th>
<th colspan="2">Year 2</th>
<th colspan="2">Year 3</th>
<th colspan="2">Year 4</th>
<th colspan="2">Year 5</th>
</tr>
<tr>
<th>Month</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
<th>Category</th>
<th>$</th>
</tr>
';
$months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$distribReceived = 1;
$returnCapital = 2;
$capitalCall = 3;
$category = "category";
$amount = "amount";
//Loop for each month
for($monthNum = 0; $monthNum < 12; ++$monthNum)
{
echo '<tr>
<th>'. $months[$monthNum] .'</th>
';
//Loop for each year
for($year = 1; $year < 6; ++$year)
{
echo '
<td>
<select name="'.$months[$monthNum].$year.'">
<option value="'.$distribReceived.'">Distribution Received</option>
<option value="'. $returnCapital .'">Return of Capital</option>
<option value="'. $capitalCall .'">Capital Call</option>
</select>
</td>
<td><input type="text" name="'.$amount.$months[$monthNum].$year.'" size="5"></td>
';
}
echo '</tr>';
}
echo' </table><p>';
?>`
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 ('','','','','',''),('','','','','',''),('','','','','',''),('','','','','',''),('','','','','',''), ('','','','','','')
Im a newbie ih php.Im trying to show drop down list values from database using this but the data not shown up.There is no error as well. Need some experts advice.
Code
<?php
include('connectdb.php');
$sql="SELECT id,name FROM companydetailstbl";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["id"];
//echo $id;
$thing=$row["name"];
$options.="<OPTION VALUE=\"$id\">".$thing;
}
?>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%">Company Name </td>
<td width="3%">:</td>
<td width="75%"><SELECT NAME="thing">
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT></td>
</tr>
<tr>
<td>Installation Date </td>
<td>:</td>
<td><input type="text" name="ins_dt" />
(ddmmyyyy)</td>
</tr>
<tr>
<td>Expiry Date </td>
<td>:</td>
<td><input type="text" name="ex_dt" />
(ddmmyyyy)</td>
</tr>
<tr>
<td>Status</td>
<td>:</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Update" />
<input type="submit" name="Submit2" value="Reset" /></td>
</tr>
</table>
Please help. Thanks
I don't know what DTD you are currently using, but according to the HTML 4.0 Specification, you need to close your option tag.
$options .= '<option value="' . $id . '">' . $thing . '</option>';
Also there,
<select name="thing">
<option value="0">Choose</option>
<?php echo $options; ?>
</select>
please try to close the tag
$options.="<OPTION VALUE=\"$id\">".$thing."</OPTION>";
also edit
<SELECT NAME="thing">
<OPTION VALUE=0>Choose</OPTION>
<?=$options?>
</SELECT>
<?php
include('connectdb.php');
$sql="SELECT id,name FROM companydetailstbl";
$result=mysql_query($sql);
?>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%">Company Name </td>
<td width="3%">:</td>
<td width="75%">
<select name="thing">
<?php
while($row = mysql_fetch_object($result)){
?>
<option value="<?=$row["id"]; ?>"><?=$row["name"]; ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Installation Date </td>
<td>:</td>
<td><input type="text" name="ins_dt" />(ddmmyyyy)</td>
</tr>
<tr>
<td>Expiry Date </td>
<td>:</td>
<td><input type="text" name="ex_dt" />(ddmmyyyy)</td>
</tr>
<tr>
<td>Status</td>
<td>:</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<input type="submit" name="Submit" value="Update" />
<input type="submit" name="Submit2" value="Reset" />
</td>
</tr>
</table>
Hope it helps
I have to use same checkboxes and dropdowns according to the if condition ,---->
<div id="5" <? if($long_term_rental!=1) {?> style="display:none" <? } else {?>style="display:block" <? } ?>>
<table width="85%" >
<tr class="td3">
<td>City </td>
<td><select style="width:100px;" name="citylong" size="1" class="textfeild1" id="citylong">
<option <? if($citylong=="None")echo "selected='selected'";?>>None</option>
<option <? if($citylong=="Palm Springs")echo "selected='selected'";?>>Palm Springs</option>
<option <? if($citylong=="Cathedral City")echo "selected='selected'";?>>Cathedral City</option>
<option <? if($citylong=="Rancho Mirage")echo "selected='selected'";?>>Rancho Mirage</option>
<option <? if($citylong=="Palm Desert")echo "selected='selected'";?>>Palm Desert</option>
<option <? if($citylong=="La Quinta")echo "selected='selected'";?>>La Quinta</option>
<option <? if($citylong=="Indian Wells")echo "selected='selected'";?>>Indian Wells</option>
</select></td></tr>
<tr class="td2">
<td align="left">Upper/Lower/Town House/Single Story</td>
<td align="left"><select style="width:100px;" name="floorlong" size="1" class="textfeild1" id="floorlong">
<option <? if($floorlong=="None")echo "selected='selected'";?>>None</option>
<option <? if($floorlong=="Upper")echo "selected='selected'";?>>Upper</option>
<option <? if($floorlong=="Lower")echo "selected='selected'";?>>Lower</option>
<option <? if($floorlong=="TH")echo "selected='selected'";?>>TH</option>
<option <? if($floorlong=="Single Story")echo "selected='selected'";?>>Single Story</option>
</select></td>
</tr>
<tr class="td2">
<td> </td>
<td >Pets Allowed : </td>
<td ><input class="textfeild1" type="checkbox" name="petslong" id="petslong" value="Pets" <? if($petslong==1) echo "checked='checked'";?>/></td>
<td>Pool : </td>
<td><input class="textfeild1" type="checkbox" name="poollong" id="poollong" value="Pool" <? if($poollong==1) echo "checked='checked'";?>/></td>
<td align="right"> </td>
</tr>
<tr class="td2">
<td> </td>
<td>Jacuzzi : </td>
<td><input class="textfeild1" type="checkbox" name="jacuzzilong" id="jacuzzilong" value="Jacuzzi" <? if($jacuzzilong==1) echo "checked='checked'";?>/></td></div>
And on condition false display the below code---->
<div id="mylng" <? if($long_term_rental!=1) {?> style="display:block" <? } else {?>style="display:none" <? } ?>>
<table width="100%" >
<tr class="td3">
<td> </td>
<td>City </td>
<td><select style="width:100px;" name="city" size="1" class="textfeild1" id="city">
<option <? if($city=="None")echo "selected='selected'";?>>None</option>
<option <? if($city=="Palm Springs")echo "selected='selected'";?>>Palm Springs</option>
<option <? if($city=="Cathedral City")echo "selected='selected'";?>>Cathedral City</option>
<option <? if($city=="Rancho Mirage")echo "selected='selected'";?>>Rancho Mirage</option>
<option <? if($city=="Palm Desert")echo "selected='selected'";?>>Palm Desert</option>
<option <? if($city=="La Quinta")echo "selected='selected'";?>>La Quinta</option>
<option <? if($city=="Indian Wells")echo "selected='selected'";?>>Indian Wells</option>
</select></td>
<td align="right" style="width: 223px;">Upper/Lower/Town House/Single Story</td>
<td align="left"><select style="width:100px;" name="floor" size="1" class="textfeild1" id="floor">
<option <? if($floor=="None")echo "selected='selected'";?>>None</option>
<option <? if($floor=="Upper")echo "selected='selected'";?>>Upper</option>
<option <? if($floor=="Lower")echo "selected='selected'";?>>Lower</option>
<option <? if($floor=="TH")echo "selected='selected'";?>>TH</option>
<option <? if($floor=="Single Story")echo "selected='selected'";?>>Single Story</option>
</select></td></tr>
<tr class="td3">
<td> </td>
<td >Pets Allowed : </td>
<td ><input class="textfeild1" type="checkbox" name="pets" id="checkbox9" value="Pets" <? if($pets==1) echo "checked='checked'";?>/></td>
<td>Pool : </td>
<td><input class="textfeild1" type="checkbox" name="pool" id="checkbox8" value="Pool" <? if($pool==1) echo "checked='checked'";?>/></td>
<td align="right"> </td>
</tr>
<tr class="td3">
<td> </td>
<td>Jacuzzi : </td>
<td><input class="textfeild1" type="checkbox" name="jacuzzi" id="checkbox6" value="Jacuzzi" <? if($jacuzzi==1) echo "checked='checked'";?>/></td>
<td> </td>
<td> </td>
</tr>
</table></div>
But the code under <div id="5" is NOT WORKINg and the same code under <div id="mylng" is working PERFECTLY
Please help
at first you did not closed your
/tr
/table
at the end of
div id=5
please send us code with your form tag maybe your fault its on you HTML