Jump to content


Photo

select problam with range.


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 October 2006 - 03:02 AM

can you see why the $day select is outputting the range as a whole and not as the select box as intrnded palease help cheers.

<?php

if($_POST['submit']){

foreach($dates as $x){

echo $x;

}

 }

echo "<form method='POST' action='' ";


$day=range(1,31);

echo"<select name='dates[]'>";

foreach($day as $d){

echo"<option value='$d'>$d</option>";
}
echo"</select>";



$month=range(1,12);

echo"<select name='dates[]'>";

foreach($month as $n){

echo"<option value='$n'>$n</option>";
}
echo"</select>";


$year=range(2006,2020);

echo"<select name='dates[]'>";

foreach($year as $y){

echo"<option value='$y'>$y</option>";
}
echo"</select><br><br>";


echo "<input type='submit' name='submit' value='send'>";

echo "</form>";


?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 marcus

marcus
  • Members
  • PipPipPip
  • Advanced Member
  • 1,842 posts
  • LocationRochester, NY

Posted 15 October 2006 - 03:05 AM

echo "<form method='POST' action='' ";

should you end that? action=''>

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 October 2006 - 03:40 AM

I came up with this as a date select box.

what do you think is it acceptable.

<?php

if($_POST['submit']){

$x=implode("-",$dates);

$result=mktime($x);// timestamp for the database

echo date("d-m-y",$result); // format timestamp any order

}
 
 
echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'> ";


$day=range(1,31);

echo"<select name='dates[]'>";

foreach($day as $d){

echo"<option value='$d'>$d</option>";
}
echo"</select>";



$month=range(1,12);

echo"<select name='dates[]'>";

foreach($month as $n){

echo"<option value='$n'>$n</option>";
}
echo"</select>";


$year=range(2006,2020);

echo"<select name='dates[]'>";

foreach($year as $y){

echo"<option value='$y'>$y</option>";
}
echo"</select><br><br>";


echo "<input type='submit' name='submit' value='send'>";

echo "</form>";


?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 October 2006 - 04:13 AM

There we go a full working select box for dates.

<?php

if($_POST['submit']){

$result1=date("d-m-Y", mktime(0, 0, 0, $dates[1], $dates[0], $dates[2]));


echo " This is the date you selected $result1";

$result2=strtotime($result1);

echo "<br>This is the timestamp for the date you selected $result2";

}
 
 
echo "<form method='POST' action='".$_SERVER['PHP_SELF']."'> ";


$day=range(1,31);

echo"<select name='dates[]'>";

foreach($day as $d){

echo"<option value='$d'>$d</option>";
}
echo"</select>";


$month=range(1,12);

echo"<select name='dates[]'>";

foreach($month as $n){


echo"<option value='$n'>$n</option>";
}
echo"</select>";


$year=range(2006,2020);

echo"<select name='dates[]'>";

foreach($year as $y){


echo"<option value='$y'>$y</option>";
}
echo"</select><br><br>";


echo "<input type='submit' name='submit' value='send'>";

echo "</form>";


?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users