我如何手动增加外键。我有 2 张桌子
餐桌时间
id-timeslot times
------------------
1 10:00
2 10:30
3 10:45
4 11:00
5 11:15
6 11:30
我有片刻的桌书
id-book id-timeslot
-------------------
1 1
2 1
下拉菜单(花费的分钟数)
<select name="minutes_booking" id="minutes_booking">
<option value="0">15 Minutes</option>
<option value="1">30 Minutes</option>
<option value="2">45 Minutes</option>
</select>
可以说,用户选择 10:00 和“30 分钟用于治疗”,我希望看起来像
id-book id-times
-------------------
1 1
2 2
php代码:
if($minutes_booking == 0) :
$mysqli->query("INSERT INTO doc_a(id_book, id_timeslot)
VALUES ('','" . $id_timeslot . "')" );
echo 'Booking has been added';
elseif($minutes_booking == 1) :
$mysqli->query("INSERT INTO doc_a(id_book, id_timeslot)
VALUES ('', '" . $id_timeslot . "')" );
$mysqli->query("INSERT INTO doc_a(id_book, id_timeslot)
VALUES ('', '" . $id_timeslot++ . "')" );
echo 'Booking has been added';
endif;