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']) ){ PHP: then user x will be taken to table 1 and if user x is set if( isset($_GET['subject']) ){ PHP: 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>'; } ?> PHP:
Sorry what do you exactly mean can't you just do: if( isset($_GET['menu']) ){ //echo / redirect to table 1 } else if( isset($_GET['subject']) ){ //echo/redirect to table 2 } PHP:
Yes it was so simple this what I think I want. I want that when a user set menu or subject then it takes user x to the table only inside the brackets of menu or subject not to display both tables together... I hope the code below achieved exactly that. let me know if it is correct if( isset($_GET['menu']) ){ $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( isset( $_GET['subject']) ) { $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>'; } PHP:
Thank you WD it worked like you said man thank you................... <?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>'; } ?> PHP: