A
Anonymous
Guest
i've been struggling to make 10 drop boxes which read from an sql database and adapt the order in which pages are displayed, i thought i had it going but i think i have a logic error im just not seeing and plus im not best programmer or even a half decent one
basically i just want it to select a record then change the Object_Lineup entry depending on which drop down box it was
heres my form:
and heres the page which saves to the database
any ideas? cheers for any help
basically i just want it to select a record then change the Object_Lineup entry depending on which drop down box it was
heres my form:
PHP:
<form method="POST" action="manageobjectordercomplete.php">
<p style="text-align: center">Part One:
<select name = "p1" size="1">
<?php
$sqlquerym1 = "Select * from natobjectscontrol";
$sql_resultm1 = mysql_query($sqlquerym1) or die("Couldn't read from database, please contact your system administrator: $sqlquerym1 - " . mysql_error());
while ($rowm1 = mysql_fetch_array($sql_resultm1)){
$order1 = $rowm1['Object_Lineup'];
$name1 = $rowm1['Object_Name'];
$id1 = $rowm1['ObjectID'];
}
if ($order1 = '1') {
echo "<option value=$id1>Currently:".$name1."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
<?php echo $order1 ?>
</p>
<p style="text-align: center">Part Two:
<select name = "p2" size="1">
<?php
$sqlquerym2 = "Select * from natobjectscontrol";
$sql_resultm2 = mysql_query($sqlquerym2) or die("Couldn't read from database, please contact your system administrator: $sqlquerym2 - " . mysql_error());
while ($rowm2 = mysql_fetch_array($sql_resultm2)){
$order2 = $rowm2['Object_Lineup'];
$name2 = $rowm2['Object_Name'];
$id2 = $rowm2['ObjectID'];
}
if ($order2 = '2') {
echo "<option value=$id2>Currently:".$name2."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
<?php echo $order2 ?>
</p>
<p style="text-align: center">Part Three:
<select name = "p3" size="1">
<?php
if ($rowm1['Object_Lineup'] == '3') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Four:
<select name = "p4" size="1">
<?php
if ($rowm1['Object_Lineup'] == '4') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Five:
<select name = "p5" size="1">
<?php
if ($rowm1['Object_Lineup'] == '5') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Six:
<select name = "p6" size="1">
<?php
if ($rowm1['Object_Lineup'] == '6') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Seven:
<select name = "p7" size="1">
<?php
$sqlquerym7 = "Select * from natobjectscontrol";
$sql_resultm7 = mysql_query($sqlquerym7) or die("Couldn't read from database, please contact your system administrator: $sqlquerym7 - " . mysql_error());
while ($rowm7 = mysql_fetch_array($sql_resultm7)){
$order7 = $rowm7['Object_Lineup'];
$name7 = $rowm7['Object_Name'];
$id7 = $rowm7['ObjectID'];
}
if ($order7 == '7') {
echo "<option value=$id7>Currently:".$name7."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Eight:
<select name = "p8" size="1">
<?php
if ($rowm1['Object_Lineup'] == '8') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Nine:
<select name = "p9" size="1">
<?php
if ($rowm1['Object_Lineup'] == '9') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p style="text-align: center">Part Ten:
<select name = "p10" size="1">
<?php
if ($rowm1['Object_Lineup'] == '10') {
echo "<option value=0A>Currently:".$rowm1['Object_Name']."</option>";
} else {
echo "<option value=0B>Do not load object</option>";
}
$sqlquery = "Select * from natobjectscontrol";
$sql_result = mysql_query($sqlquery) or die("Couldn't read from database, please contact your system administrator: $sqlquery - " . mysql_error());
while($row = mysql_fetch_array($sql_result)) {
echo "<option value=".$row['ObjectID'].">".$row['Object_Name']."</option>";
}
?>
</select>
</p>
<p align="center"> </p>
<p align="center"><input type="submit" value="Save" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
and heres the page which saves to the database
PHP:
<?php
if ($p1 == 'OB') {
} else {
if ($p1 == 'OA') {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '1' WHERE ObjectID = '$p1' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '1' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '1' WHERE ObjectID = '$p1' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p2 == 'OB') {
} else {
if ($p2 == 'OA') {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '2' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '2' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '2' WHERE ObjectID = '$p2' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p3 == 'OB') {
} else {
if ($p3 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '3' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '3' WHERE ObjectID = '$p3' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p4 == 'OB') {
} else {
if ($p4 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '4' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '4' WHERE ObjectID = '$p4' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p5 == 'OB') {
} else {
if ($p5 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '5' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '5' WHERE ObjectID = '$p5' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p6 == 'OB') {
} else {
if ($p6 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '6' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '6' WHERE ObjectID = '$p6' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p7 == 'OB') {
} else {
if ($p7 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '7' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '7' WHERE ObjectID = '$p7' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p8 == 'OB') {
} else {
if ($p8 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '8' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '8' WHERE ObjectID = '$p8' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p9 == 'OB') {
} else {
if ($p9 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '9' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '9' WHERE ObjectID = '$p9' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
if ($p10 == 'OB') {
} else {
if ($p10 == 'OA') {
} else {
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = 'Do not use' WHERE Object_Lineup = '10' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
$sqlstatement = "UPDATE natobjectscontrol SET Object_Lineup = '10' WHERE ObjectID = '$p10' ";
$sql_result = mysql_query($sqlstatement) or die("Couldn't input into database, please contact your system administrator: $sqlstatement - " . mysql_error());
}
}
?>
any ideas? cheers for any help