Search the Community
Showing results for tags 'buttonand drop'.
-
Hi I was wondering is it possible to have a query ran after an item is selected from a dropdown menu? If not how do I create a button to run the query. Also how do I use the value from the drop down in my where clause? <?php //create_cat.php include 'connect.php'; include 'header.php'; echo '<h2>Update Rewards</h2>'; if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 1 ) { //the user is not an admin echo 'Sorry, you do not have sufficient rights to access this page.'; } else { $sql = "Select user_name from users"; $result = mysql_query($sql); if(!$result) { //the query failed, uh-oh :-( echo 'Error while selecting from database. Please try again later.'; } else { $dropdown = "<select name='mem'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['user_name']}'>{$row['user_name']}</option>"; } $dropdown .= "\r\n</select>"; echo $dropdown; } $post_sql = "select cat_name, point_earn, max_point from rewards where member = '" . mysql_real_escape_string($_POST['mem']) . "'"; $result_post = mysql_query($post_sql); if(!$result_post) { //the query failed, uh-oh :-( echo 'Error while selecting rewards from database. Please try again later.'; } else { echo '<table border="1"> <tr> <th>Category</th> <th>Points Earned</th> <th>Max Points</th> </tr>'; while($row = mysql_fetch_assoc($result_post)) { echo '<tr>'; echo '<td>' . $row['cat_name'] . '</td>'; echo '<td>'. $row['point_earn']. '</td>'; echo '<td>' . $row['max_point']. '</td>'; echo '</tr>'; } } } ?>