Php 我对显示结果值的循环有问题 $array\u of_time=array(); $start_time=strottime($app_date 07:00); $end_time=strottime($app_date 22:00); $mins=04*60; while($start\u time$value) { 对于($i=0;$i
这里foreach循环可以和for循环一样运行尽可能多的时间,但是我想展示与foreach值和for循环值不匹配的链接Php 我对显示结果值的循环有问题 $array\u of_time=array(); $start_time=strottime($app_date 07:00); $end_time=strottime($app_date 22:00); $mins=04*60; while($start\u time$value) { 对于($i=0;$i,php,mysql,for-loop,foreach,Php,Mysql,For Loop,Foreach,这里foreach循环可以和for循环一样运行尽可能多的时间,但是我想展示与foreach值和for循环值不匹配的链接 foreach循环值(如7:20AM)不是来自数据库,而是来自数据库的for循环值(如7:20AM),因此如果7:20AM==7:20AM,则它运行的if语句工作正常,但问题是,如果我在for循环中获得2个值,它将运行2次。它应该只运行我的div一次。如果浏览了您的站点,我会修改副本: $array_of_time = array (); $start_time =
foreach循环值(如7:20AM)不是来自数据库,而是来自数据库的for循环值(如7:20AM),因此如果7:20AM==7:20AM,则它运行的if语句工作正常,但问题是,如果我在for循环中获得2个值,它将运行2次。它应该只运行我的div一次。如果浏览了您的站点,我会修改副本:
$array_of_time = array ();
$start_time = strtotime ("$app_date 07:00");
$end_time = strtotime ("$app_date 22:00");
$mins = 04 * 60;
while ($start_time <= $end_time)
{
$array_of_time[] = date ('h:i a', $start_time);
$start_time += $mins;
}
echo "<div style='width:700px' class='time_slot_div'>";
echo "<p class='time_slot_p'> Time Slot :</p>";
foreach($array_of_time as $key=>$value)
{
for($i = 0; $i < count($app_data); $i++)
{
$book_time=$app_data[$i]["appointment_time"];
if($value==$book_time)
{
echo "<a class='time_slot_a_book'>$value</a> ";
} else {
echo "<a href='#' onclick='get_time_value(\"$value\");' class='time_slot_a'>$value</a> ";
}
}
}
echo "</div>";
$array\u of_time=array();
$start_time=strottime($app_date 07:00);
$end_time=strottime($app_date 22:00);
$mins=04*60;
while($start\u time$value)
{
//
//获得任命国:
//
$BAP=false;
对于($i=0;$i
?
好点了吗?你能再解释一下你想要什么吗?是否也要在foreach($array\u of\u time as$key=>$value)中中断?通过示例尽快显示。foreach循环显示从上午7:00到晚上10:00的时间,时隙间隔为4分钟,例如上午7:00到上午7:04到上午7:08等等。。。。第二个循环是for循环,它为数据库中保存的时隙获取值,假设数据库中有两个单独的行中保存了值7:04 am 7:08 am,那么它将使用查询获取值。for循环将检查在我们的情况下保存了多少时隙,即7:04 am 7:08 am,然后它将与foreach匹配循环值如果匹配,它将进入if语句,而不是else语句。最好在问题中解释得更多。给出一个示例时间列表,以及您希望显示为时间的确切内容…请转到此处,以用户名登录:ajit密码:123,然后在登录后转到约会并选择/单击“添加约会”表单将出现后请选择医生姓名和日期,然后数据将显示在“保存”按钮下方时间重复。我不想重复此操作timethanx jacouh我得到了这个问题的解决方案:D
$array_of_time = array ();
$start_time = strtotime ("$app_date 07:00");
$end_time = strtotime ("$app_date 22:00");
$mins = 04 * 60;
while ($start_time <= $end_time)
{
$array_of_time[] = date ('h:i a', $start_time);
$start_time += $mins;
}
echo "<div style='width:700px' class='time_slot_div'>";
echo "<p class='time_slot_p'> Time Slot :</p>";
foreach($array_of_time as $key=>$value)
{
//
// get the appointing state:
//
$bAppointed = false;
for($i = 0; $i < count($app_data); $i++)
{
$book_time = $app_data[$i]["appointment_time"];
$bAppointed = $value == $book_time;
if($bAppointed)
{
break;
}
}
//
// print the time slot:
//
if($bAppointed)
{
echo "<a class='time_slot_a_book'>$value</a> ";
} else {
echo "<a href='#' onclick='get_time_value(\"$value\");' class='time_slot_a'>$value</a> ";
}
}
echo "</div>";