ondi Posted December 18, 2008 Share Posted December 18, 2008 I've a drop down list and a button created no problems. However, when the button is clicked, it only takes you to the same page, no matter which drop down option you chose. <?php // //Haetaan kaikki pelaajat dropdownia varten // $sql = ' SELECT P.PlayerID AS id, P.PlayerLastName AS lastname, P.PlayerFirstName AS firstname, P.PlayerPublish AS publish FROM tplss_seasons S LEFT OUTER JOIN tplss_players P ON P.PlayerID = S.SeasonPlayerID '; if($defaultseasonid == 0) { $sql .= " WHERE P.PlayerID != '' AND P.PlayerPublish = '1' GROUP BY id ORDER BY firstname, lastname"; } else { $sql .= " AND S.SeasonID = '$defaultseasonid' WHERE P.PlayerID != '' AND P.PlayerPublish = '1' GROUP BY id ORDER BY firstname, lastname"; } $query = mysql_query("$sql", $connection) or die(mysql_error()); echo"<br>$txt_change_player: <select name=\"playerid\">"; while($data = mysql_fetch_array($query)) { if($data['id'] == $id) { echo"<option value=\"$data[id]\" SELECTED>$data[firstname] $data[lastname]</option>\n"; } else { echo"<option value=\"$data[id]\">$data[firstname] $data[lastname]</option>\n"; } } echo"</select> <input type=\"submit\" name=\"change_player\" value=\"$txt_change\">"; mysql_free_result($query); $ttl = (($_SESSION['getAdditional'] + 1) % 2) ? "Show": "Hide"; ?> Here's my code, can anyone help me with whats going wrong? Thanks. Link to comment https://forums.phpfreaks.com/topic/137528-button-code/ Share on other sites More sharing options...
premiso Posted December 18, 2008 Share Posted December 18, 2008 You do not have a <form tag in that code...also if you want to change when the new option is selected you need to use Javascript's "onChange" event. Link to comment https://forums.phpfreaks.com/topic/137528-button-code/#findComment-718682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.