co.ador Posted September 9, 2009 Share Posted September 9, 2009 guys if you notice in the code below query one is going to display it's content in the table below if user x set it. But I have different tables and layouts for each query. I want that when user x set if( isset($_GET['menu']) ){ then user x will be taken to table 1 and if user x is set if( isset($_GET['subject']) ){ then user x will be taken to table 2 in this moment both query when are set are taken to the same table. Can anybody help... thank you. <?php $submenu = false; // decide which is the correct query if( isset($_GET['menu']) ){ $query = "SELECT id, submenus, image, FROM submenu WHERE id= " . (int) $_GET['menu']; } elseif( isset( $_GET['subject']) ) { $query = "SELECT id, Subject, image, FROM subjects WHERE id= " . (int) $_GET['subject']; } else{ // if neither is set, do what? } // take a look at which was chosen echo $query ; // then deal with the query and display the table $result = mysql_query($query, $connection); { echo '<table border="0" cellspacing="0" cellpadding="0" > <td></td> </table>'; } ?> Link to comment https://forums.phpfreaks.com/topic/173711-help-with-isset-queries-taking-user-x-to-table-x/ Share on other sites More sharing options...
Rommeo Posted September 9, 2009 Share Posted September 9, 2009 That code should work i think ? What's the thing that you could not do ? Link to comment https://forums.phpfreaks.com/topic/173711-help-with-isset-queries-taking-user-x-to-table-x/#findComment-915698 Share on other sites More sharing options...
co.ador Posted September 10, 2009 Author Share Posted September 10, 2009 this is what I wanted <?php $submenu = false; $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null; $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; $menu_type = isset($_GET['menu_type']) && is_string($_GET['menu_type'])?$_GET['menu_type']:null ?> if ($prod){ $query = "SELECT id, submenus, image, FROM submenu WHERE id= " . (int) $_GET['menu']; echo $query ; $result = mysql_query($query, $connection); { echo '<table border="0" cellspacing="0" cellpadding="0" > <td>different</td><td>different</td> </table>'; } elseif( $cat) { $query = "SELECT id, Subject, image, FROM subjects WHERE id= " . (int) $_GET['subject']; echo $query ; $result = mysql_query($query, $connection); { echo '<table border="0" cellspacing="0" cellpadding="0" > <td></td> </table>'; } ?> Link to comment https://forums.phpfreaks.com/topic/173711-help-with-isset-queries-taking-user-x-to-table-x/#findComment-915785 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.