Jump to content

Recommended Posts

hey guys i have a script that selects client from a databse.now that client is either in a programme simple or combo.

 

there is a link on that page that gets a grid with exercises on it.

 

now i need a script between that process thats like if the client is simple fetch page...if client is combo fetch page x..

Link to comment
https://forums.phpfreaks.com/topic/136970-if/
Share on other sites

sorry fergot to post it..lol

 

ok so i have 2 questions in this:

<? 
// Connects to your Database
mysql_connect("localhost", "l", "techker") or die(mysql_error());
mysql_select_db("techker_llls") or die(mysql_error());

$id = mysql_escape_string($_GET['id']);
$q = "SELECT * FROM cardio_select WHERE id = '$id'";
$res = mysql_query($q);
$row = mysql_fetch_assoc($res);



$plan = "$row['simple']";      //is this ok?will it get table simple?
$plan2 = "$row['combo']";

if ( $plan == "on" ) {;         //if that table's value is on then it should get page x
}
elseif($plan2 == "on"){;       //if this one is on then it gets  page b
} 
?>

 

now it's the getting that page the part were i freeze..

 

i was looking at fetch but i think it is only for arays.

 

then i looked at another page i did and the echo

echo "<meta http-equiv=Refresh content=4;url=emplacement.php>";

 

but was woundering if 2 would the script get confused?

Link to comment
https://forums.phpfreaks.com/topic/136970-if/#findComment-715416
Share on other sites

ok i got it going i remove the " " cause it was giving me a white space error..

 

<? 
// Connects to your Database
mysql_connect("localhost", "l_l", "l") or die(mysql_error());
mysql_select_db("techker_l") or die(mysql_error());

$id = mysql_escape_string($_GET['id']);
$q = "SELECT * FROM cardio_select WHERE id = '$id'";
$res = mysql_query($q);
$row = mysql_fetch_assoc($res);


$plan =$row['simple'];
$plan2 =$row['combo'];


if ( $plan == "on" ) {
echo "<meta http-equiv=Refresh content=2;url=client_cardio.php>";;
}
elseif($plan2 == "on"){
echo "<meta http-equiv=Refresh content=2;url=emplacement.php>";;
} 
?>

 

is this the write way to do it?

Link to comment
https://forums.phpfreaks.com/topic/136970-if/#findComment-715425
Share on other sites

Why?

$plan = "$row['simple']";      //is this ok?will it get table simple?
$plan2 = "$row['combo']";

simpler if you do

$plan = $row['simple'];      //is this ok?will it get table simple?
$plan2 = $row['combo'];

 

for this you could do

if ( $plan == "on" ) 
{         //if that table's value is on then it should get page x
echo file_get_contents("filename.php");
//or
include("file.php");
}
elseif($plan2 == "on")
{       //if this one is on then it gets  page b
echo file_get_contents("filename.php");
//or
include("file.php");
} 

or header("Location:filename.php"); would work, as long as there is no whitespace of HTML before the header

Link to comment
https://forums.phpfreaks.com/topic/136970-if/#findComment-715426
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.