dean7 Posted November 4, 2010 Share Posted November 4, 2010 Hi all, ive got a script ive finishing coding from the other day, but ive got a slight problem with it. <?php if ($fetch->missions == "4"){ // Mission 4, Toyota Aygo up to 500MPH $car = "Toyota Aygo"; if ($garage->car == $car && $garage->mph == "500"){ $rightcar = "Yes"; }else{ $rightcar = "No"; } if (strip_tags($_POST['submit'])){ if ($rightcar == "Yes"){ echo ("<table width='30%' cellpadding='0' align='center' cellspacing='0' border='1' class='table'> <tr> <td class='header' align='center'>Well Done!</td> </tr> <tr> <td>You Successfully Completed Mission 3!</td> </tr> </table><br />"); $newmoney = $fetch->money + 70000000; $newrep = $fetch->rep + 750000; mysql_query ("UPDATE users SET money='$newmoney' WHERE username='$username'"); mysql_query ("UPDATE users SET rep='$newrep' WHERE username='$username'"); mysql_query ("UPDATE users SET missions='5' WHERE username='$username'") or die ("Error - Query : Line 121 : " . mysql_error()); mysql_query ("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$username', 'System', 'Well done! <br /> As You completed Mission 4 Successfully we will reward you with<br /> £70,000,000 Money<br /> 750,000 Rep!', '$date', '0', '0', '0' )"); } } } // Mission 4 ?> <?php if ($fetch->missions == "4"){ ?> <form action="" method="POST" name="mission4"> <table width="50%" cellpadding="0" cellspacing="0" border="1" class="table" align="center"> <tr> <td class='header' align='center'>Mission 4</td> </tr> <tr> <td>Now SD Stars can now see your progressing, they have asked you if you can get a Toyota Aygo up to 500MPH. You must get it to them without any damage to prove your werthy!</td> </tr> <tr> <td align='center' class='header'>Select Your Car:</td> </tr> <tr> <td><select class="dropbox"> <option selected>Pick Car</option> <?php $get=mysql_query("SELECT * FROM garage WHERE owner='$username' AND car='Toyota Aygo' AND mph='500'"); while($stats=mysql_fetch_object($get)){ echo "<option value=?carname=$stats->id>$stats->car, $stats->damage%, $stats->mph MPH</option>"; } ?></select></td> </tr> <tr> <td class='omg'><input type="submit" name="submit" class="button" value="Send Car!"></td> </tr> </table> </form> <?php } ?> I blive it works apart from the Drop Down Box. It selects all the cars its suppose to but when I pick the car and press submit it just basicly refreshes the page :S. I'm not sure why its doing it . Can any one else see the problem? Thanks for any help given Link to comment https://forums.phpfreaks.com/topic/217739-drop-down-boxs/ Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2010 Share Posted November 4, 2010 Your <select> has no name= attribute, and what is this supposed to be doing? How are you extracting/using those values? <option value=?carname=$stats->id>$stats->car, $stats->damage%, $stats-> You also run three consecutive INSERT queries on the same table. Those can be consolidated from this mysql_query ("UPDATE users SET money='$newmoney' WHERE username='$username'"); mysql_query ("UPDATE users SET rep='$newrep' WHERE username='$username'"); mysql_query ("UPDATE users SET missions='5' To this mysql_query ("UPDATE users SET money='$newmoney', rep='$newrep', missions = '5' WHERE username='$username'") or die( mysql_error() ); Link to comment https://forums.phpfreaks.com/topic/217739-drop-down-boxs/#findComment-1130253 Share on other sites More sharing options...
dean7 Posted November 4, 2010 Author Share Posted November 4, 2010 Your <select> has no name= attribute, and what is this supposed to be doing? How are you extracting/using those values? <option value=?carname=$stats->id>$stats->car, $stats->damage%, $stats-> You also run three consecutive INSERT queries on the same table. Those can be consolidated from this mysql_query ("UPDATE users SET money='$newmoney' WHERE username='$username'"); mysql_query ("UPDATE users SET rep='$newrep' WHERE username='$username'"); mysql_query ("UPDATE users SET missions='5' [code=php:0] To this [code=php:0] mysql_query ("UPDATE users SET money='$newmoney', rep='$newrep', missions = '5' WHERE username='$username'") or die( mysql_error() ); The <select> tag is just there so the user picks the right car for the mission. I wernt sure of any other ways of doing it. Link to comment https://forums.phpfreaks.com/topic/217739-drop-down-boxs/#findComment-1130257 Share on other sites More sharing options...
Pikachu2000 Posted November 4, 2010 Share Posted November 4, 2010 Without a name= attribute, the value won't be passed, rendering it useless. Link to comment https://forums.phpfreaks.com/topic/217739-drop-down-boxs/#findComment-1130286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.