Skip to main content
GeoEngineering
Participant
April 12, 2017
Question

PHP And Dreamweaver?

  • April 12, 2017
  • 2 replies
  • 496 views

Hey there!

Google doesn't really help me, not any other php tutorials or whatever, so I am asking here.

I want to add opening hours to my companies web page. So far so good, worked on a php script and took a few examples from GitHub.

I got a working php script saying if we are in the office or not.

Now how do I put that in my Contact div? Or how do I implement it in the website?

This is my php code that I used:

!

<?php

    date_default_timezone_set('Europe/Vienna'); 

    $weekday = date("H:i");

if ($weekday == "Friday") {

        $open_from = "08:30";

        $opten_to = "15:00";

    }

    elseif ($weekday == "Saturday" || $weekday == "Sunday") {

        $open_from = "00:00";

        $open_to = "00:01";

    }

    else {

        $open_from = "08:30";

        $open_to = "17:00";

    }

    if (date("H:i") < $open_from || date("H:i") > $open_to ) {

        print "nur via E-Mail erreichbar, wir leben ja nicht im Büro :-)";

    }

    else {

        print "Sie können uns jetzt anrufen, wir sind erreichbar :-)";

    }

?>

This topic has been closed for replies.

2 replies

Legend
April 12, 2017

The slightly revised php script:

<?php

date_default_timezone_set('Europe/Vienna');

$weekday = date('l');

$opening_times = date("H:i");

if ($weekday == "Friday") {

$open_from = "08:30";

$open_to = "15:00";

}

elseif ($weekday == "Saturday" || $weekday == "Sunday") {

$open_from = "00:00";

$open_to = "00:01";

}

else {

$open_from = "08:30";

$open_to = "17:00";

}

if (date("H:i") < $open_from || date("H:i") > $open_to ) {

$closed = "We are closed for business";

}

else {

$open = "We are open for business";

}

?>

The html/php to include on your page where you want the opening/closed time/message displayed:

<div class="opening_hours">

<?php if(isset($closed)) { ?>

<h4><?php echo $closed; ?></h4>

<?php } else { ?>

<h4><?php echo $open; ?></h4>

<?php echo "<p>$weekday $open_from - $open_to</p>"; ?>

<?php } ?>

</div>

<!-- end opening hours -->

See if that works.

GeoEngineering
Participant
April 12, 2017

this is what comes out. I honestly do not have a single idea on how I can make this work :/

Legend
April 12, 2017

Are you working in a .php page? What happens if you run the page through a browser.

Open a new DW document, delete any code inside it and paste in the code below as it is. Save it as opening_times.php and then run the page through your local server set up or upload the page to your remote server, assuming it supports php and browse out to the page. Once you establish a simple page works you should then be able to transfer the code (copy and paste) into the page where you require it to be.

<?php

date_default_timezone_set('Europe/Vienna');

$weekday = date('l');

$opening_times = date("H:i");

if ($weekday == "Friday") {

$open_from = "08:30";

$open_to = "15:00";

}

elseif ($weekday == "Saturday" || $weekday == "Sunday") {

$open_from = "00:00";

$open_to = "00:01";

}

else {

$open_from = "08:30";

$open_to = "17:00";

}

if (date("H:i") < $open_from || date("H:i") > $open_to ) {

$closed = "We are closed for business";

}

else {

$open = "We are open for business";

}

?>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8" />

<title>Opening Times</title>

</head>

<body>

<div class="opening_hours">

<?php if(isset($closed)) { ?>

<h4><?php echo $closed; ?></h4>

<?php } else { ?>

<h4><?php echo $open; ?></h4>

<?php echo "<p>$weekday $open_from - $open_to</p>"; ?>

<?php } ?>

</div>

<!-- end opening hours -->

</body>

</html>

BenPleysier
Community Expert
Community Expert
April 12, 2017
Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!