Php 在表中垂直显示数据库中的数据
我想在表中垂直显示与日期相关的时隙。 这是此代码的输出:Php 在表中垂直显示数据库中的数据,php,html,mysql,Php,Html,Mysql,我想在表中垂直显示与日期相关的时隙。 这是此代码的输出: 但我想显示水平显示的时间,应该垂直显示。例如,第一行的1-3、3-5、5-7应显示在星期一下方,然后下一行应显示在星期二下方,依此类推。尝试使用如下查询: //This code to split time into intervals $starttime = $row['start_time']; // your start time $endtime = $row['end_time']; // En
但我想显示水平显示的时间,应该垂直显示。例如,第一行的1-3、3-5、5-7应显示在星期一下方,然后下一行应显示在星期二下方,依此类推。尝试使用如下查询:
//This code to split time into intervals
$starttime = $row['start_time']; // your start time
$endtime = $row['end_time']; // End time
$duration = $row['slot_time'];
$array_of_time = array ();
$start_time = strtotime ($starttime); //change to strtotime
$end_time = strtotime ($endtime); //change to strtotime
$add_mins = $duration * 60;
while ($start_time <= $end_time) // loop between time
{
echo '<td>';
echo "<div align=\"center\">";
print_r(date ("h:i", $start_time) ."-". date("h:i", $start_time += $add_mins));
//
echo "</br><input type=\"radio\" name=\"texi\" value=\"1\" ></input>";
echo '</td>' ;
echo '</div>';
}
echo "</tr>";
echo "</tbody>";
}
mysqli_close($con);
echo "</table>
</div>
<input type=\"submit\" value=\"Book Slot\" class=\"button_drop\">
</form>";
?>
这样可以更容易地处理数据。我看不到您的确切数据结构,但看起来您应该得到7x01:00-03:00
,然后是7x03:00-05:00
,等等。每一组都应该按天排列。然后,您可以按照数据来自数据库的顺序写出
s。跟踪日期
值的变化时间(或最多7次),并在该时间开始新的
//This code to split time into intervals
$starttime = $row['start_time']; // your start time
$endtime = $row['end_time']; // End time
$duration = $row['slot_time'];
$array_of_time = array ();
$start_time = strtotime ($starttime); //change to strtotime
$end_time = strtotime ($endtime); //change to strtotime
$add_mins = $duration * 60;
while ($start_time <= $end_time) // loop between time
{
echo '<td>';
echo "<div align=\"center\">";
print_r(date ("h:i", $start_time) ."-". date("h:i", $start_time += $add_mins));
//
echo "</br><input type=\"radio\" name=\"texi\" value=\"1\" ></input>";
echo '</td>' ;
echo '</div>';
}
echo "</tr>";
echo "</tbody>";
}
mysqli_close($con);
echo "</table>
</div>
<input type=\"submit\" value=\"Book Slot\" class=\"button_drop\">
</form>";
?>
SELECT day FROM time_slot ORDER BY time_slot, day;