Jump to content

help with isset queries! taking user x to table x


co.ador

Recommended Posts

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>';

}

?>

 

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>';


}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.