[PHP] You there Jubba :)

Hi, well since jubba is the more experiencied php guru freak coder(no offense!) around kirupians

i got this reservation form, but now they want that the form can display the day(number) of the reservation

they just get in the email the form value of the <option> of the days… like… Friday = 2 etc…

They want it to be like Friday = “11 Feb 2003 - Friday” or something similar… maybe 11/02/03 dont know which way is easier… can you help me out here… still learning

maybe i can work it out something like…

if ($Dia = “2”)
{
$Dia = “Friday”;
}

and so on… but… what about the DATE?

help me…
:q:

Ha. I haven’t read thru your question yet, but I am no where near the more experience PHP coder. h88 is much better than I, and I’ms ure there are a few others. :slight_smile: Reading question now, in between bites of my sandwich…

To do exactly what you want done you would want this:


print date("j M y - l");

There are many other ways to format the date. Check out the manual:

http://www.php.net/manual/tw/function.date.php

If you need anything else just let me know…

Cheers,
Jubs :moustache

wht i need is…

to display the exact date. look.


<select name="Dia" size="3">
	<option value="1" SELECTED>Thursday</option>
	<option value="2">Friday</option>
	<option value="3">Saturday</option>
</select>

i got only the day, but i need it to display the date of the day, of that week. (confusing?)

something like…


<select name="Dia" size="3">
	<option value="1" SELECTED>Thursday, Feb 13 2003</option>
	<option value="2">Friday, Feb 14 2003</option>
	<option value="3">Saturday, Feb 15 2003</option>
</select>

so the next week the date automatically changes… maybe is just alil php code? maybe not?

Plz help…
thanks…

I’m still a little unclear on what you want, but here is what i have so far.


<?
$dayArray = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$monArray = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Oct", "Nov", "Dec");

$nDay = date("w");
$nMonth = date("n");
$nDate = date("d");
$nYear = date("Y");

$nDate2 = $nDate + 1;
$nDate3 = $nDate + 2;

$nDay2 = $nDay + 1;
$nDay3 = $nDay + 2;

print "<select name=\"Dia\" size=\"3\">";
print "<option value=\"1\" SELECTED>$dayArray[$nDay], $monArray[$nMonth] $nDate, $nYear</option>";
print "<option value=\"2\">$dayArray[$nDay2], $monArray[$nMonth] $nDate2, $nYear</option>";
print "<option value=\"3\">$dayArray[$nDay3], $monArray[$nMonth] $nDate3, $nYear</option>";
print "</select>";
?>

There are probably other, better ways to do this, but right now I am too busy to write up a function for it. Hopefully you will understand the basic Idea. The code gets the day, date, month and year then I use those numbers and put them into the array and then prints them out in the HTML

i couldn’t just use


date("l, M d Y");

because you can’t edit it to chage the date it displays, like if you need future or past dates…

The long code will change every day… this is what it looks like:

http://www.livetoskateboard.com/php/date.php

is there a way to do it only every thursday Friday and Saturday???

i got that idea… but i only need it for those 3 days…

any idea?

either just use If statements to see if the day value is greater than saturday and then make it print out the new dates. I don’t have the time right now to actually try it out… but if statements seem to be the easiest way right now…

or you could try to write a function out…

ok thanks. ill see what i can work out :slight_smile:

You mean something like this jubba??


<?
$dayArray = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$monArray = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Oct", "Nov", "Dec");

$nMonth = date("n") - 1;
$nYear = date("Y");

$nDate = date("d");
$nDay = date("w");
if ($nDay = "0") 
{
   $nDate = $nDate + 4;  
   $nDate2 = $nDate + 5;
   $nDate3 = $nDate + 6;
   $nDay = $nDay + 4;
   $nDay2 = $nDay + 5;
   $nDay2 = $nDay + 6;

}
if ($nDay = "1") 
{
   $nDate = $nDate + 3;  
   $nDate2 = $nDate + 4;
   $nDate3 = $nDate + 5;
   $nDay = $nDay + 3;
   $nDay2 = $nDay + 4;
   $nDay2 = $nDay + 5;
}
if ($nDay = "2") 
{
   $nDate = $nDate + 2;  
   $nDate2 = $nDate + 3;
   $nDate3 = $nDate + 4;
   $nDay = $nDay + 2;
   $nDay2 = $nDay + 3;
   $nDay2 = $nDay + 4;
}
if ($nDay = "3") 
{
   $nDate = $nDate + 1;  
   $nDate2 = $nDate + 2;
   $nDate3 = $nDate + 3;
   $nDay = $nDay + 1;
   $nDay2 = $nDay + 2;
   $nDay2 = $nDay + 3;
}
if ($nDay = "4") 
{
   $nDate = $nDate + 0;  
   $nDate2 = $nDate + 1;
   $nDate3 = $nDate + 2;
   $nDay = $nDay + 0;
   $nDay2 = $nDay + 1;
   $nDay2 = $nDay + 2;
}
if ($nDay = "5") 
{
   $nDate = $nDate - 1;  
   $nDate2 = $nDate + 0;
   $nDate3 = $nDate + 1;
   $nDay = $nDay - 1;
   $nDay2 = $nDay + 0;
   $nDay2 = $nDay + 1;
}
if ($nDay = "6") 
{
   $nDate = $nDate - 2;  
   $nDate2 = $nDate - 1;
   $nDate3 = $nDate + 1;
   $nDay = $nDay - 2;
   $nDay2 = $nDay - 1;
   $nDay2 = $nDay + 1;
}
print "<select name=\"Dia\" size=\"3\">";
print "<option value=\"1\" SELECTED>$dayArray[$nDay], $monArray[$nMonth] $nDate, $nYear</option>";
print "<option value=\"2\">$dayArray[$nDay2], $monArray[$nMonth] $nDate2, $nYear</option>";
print "<option value=\"3\">$dayArray[$nDay3], $monArray[$nMonth] $nDate3, $nYear</option>";
print "</select>";

if that works for you then yeah. :slight_smile:

not working lol :stuck_out_tongue:

i added a ECHO to each if stat. and everyone of them prints out…

then i added a == to the IF statements and then 2 echos print out…

this is getting messy…


<?
$dayArray = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$monArray = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Oct", "Nov", "Dec");

$nMonth = date("n") - 1;
$nYear = date("Y");

$nDate = date("d");
$nDate2 = date("d");
$nDate3 = date("d");
$nDay = date("w");
$nDay2 = date("w");
$nDay3 = date("w");

if ($nDay == "0") 
{
   $nDate = $nDate + 4;  
   $nDate2 = $nDate + 5;
   $nDate3 = $nDate + 6;
   $nDay = $nDay + 4;
   $nDay2 = $nDay + 5;
   $nDay3 = $nDay + 6;
    echo "DIA 0";

}
if ($nDay == "1") 
{
   $nDate = $nDate + 3;  
   $nDate2 = $nDate + 4;
   $nDate3 = $nDate + 5;
   $nDay = $nDay + 3;
   $nDay2 = $nDay + 4;
   $nDay3 = $nDay + 5;
   echo "DIA 1";
}
if ($nDay == "2") 
{
   $nDate = $nDate + 2;  
   $nDate2 = $nDate + 3;
   $nDate3 = $nDate + 4;
   $nDay = $nDay + 2;
   $nDay2 = $nDay + 3;
   $nDay3 = $nDay + 4;
   echo "DIA 2";
}
if ($nDay == "3") 
{
   $nDate = $nDate + 1;  
   $nDate2 = $nDate + 2;
   $nDate3 = $nDate + 3;
   $nDay = $nDay + 1;
   $nDay2 = $nDay + 2;
   $nDay3 = $nDay + 3;
   echo "DIA 3";
}
if ($nDay == "4") 
{
   $nDate = $nDate - 3;  
   $nDate2 = $nDate2 -2;
   $nDate3 = $nDate3 -1;
   $nDay = $nDay + 1;
   $nDay2 = $nDay2 + 4;
   $nDay3 = $nDay3 + 5;
   echo "DIA 4";
}
if ($nDay == "5") 
{
   $nDate = $nDate - 1;  
   $nDate2 = $nDate + 0;
   $nDate3 = $nDate + 1;
   $nDay = $nDay - 1;
   $nDay2 = $nDay + 0;
   $nDay3 = $nDay + 1;
   echo "DIA 5";
}
if ($nDay == "6") 
{
   $nDate = $nDate - 2;  
   $nDate2 = $nDate - 1;
   $nDate3 = $nDate + 1;
   $nDay = $nDay - 2;
   $nDay2 = $nDay - 1;
   $nDay3 = $nDay + 1;
   echo "DIA 6";
}
print "<select name=\"Dia\" size=\"3\">";
print "<option value=\"1\" SELECTED>$dayArray[$nDay], $monArray[$nMonth] $nDate, $nYear</option>";
print "<option value=\"2\">$dayArray[$nDay2], $monArray[$nMonth] $nDate2, $nYear</option>";
print "<option value=\"3\">$dayArray[$nDay3], $monArray[$nMonth] $nDate3, $nYear</option>";
print "</select>";

?>

its like they will always activate the IF below… cos the $ndate in the if above got incremented by one or 2… and so on…

what can i do… maybe in the IF selected clear the Vars like $ndate = “” or something?

use else if statements.

http://www.php.net/manual/tw/control-structures.elseif.php