Jump to content

[SOLVED] Show/Hide True/False


verdrm

Recommended Posts

you could use it like this

 

 

function calendarfunction($true_or_false) {
  if ($true_or_false == true) {
      echo 'Calandar is active';
  } else {
      echo 'Calandar is inactive';
  }
}

$show_calendar = false;

calendarfunction($show_calendar);

 

 

 

If that is what you ment?

 

Regards

Liam

Link to comment
Share on other sites

Thanks. I worked it out.

 

Now my question is this. I have a form that can update the database with the user's choice (either 'true' or 'false').

 

Example: $showcalendar = true;

 

Is there a way to replace "true" above with a statement that can interact with MySQL and find out whether they chose TRUE or FALSE? So if the user chose "false" it wouldn't show up?

Link to comment
Share on other sites

I would like to do it this way, if possible:

 

$show = mysql_query("SELECT choice FROM calendar WHERE dom_id = '$domain_id' ");

$showcalendar = $show; <-- THIS VALUE, if true, would show calendar...$show needs to be able to be replaced with TRUE or FALSE

 

//Determine whether or not to show the calendar

if($showcalendar == true) {

 

The problem that I am having is how do I query MySQL to deliver that value and replace "$show" with that value?

Link to comment
Share on other sites

maybe

$show = $_POST['value'];//i dont know if you have post but this might be good sample
$query = "SELECT choice FROM calendar WHERE dom_id = '$domain_id' ";
$result=mysql_query($query);
if ($result){
	$value = mysql_fetch_array($result);
if ($show ==  $value['choice']){
//just show calendar base on the query 
}
else{
	mysql_query('update calendar set  choice = "$show" where yourcondition');
	//show calendar based on the users post
}
}

Link to comment
Share on other sites

I think what I'm looking for is a bit less complicated. Basically I just want to query the column "choice", and if that column has the value "false" it should not show the calendar. If the value is "true", then it should. The problem I am having is in BOLD. I can SELECT the choice from the database, but how do I replace $value with that choice?

 

$value = MySQL SELECT statement here....

 

$showcalendar = $value

 

//Determine whether or not to show the calendar

if($showcalendar == true) {

Link to comment
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.