gpt4 book ai didi

php - 在插入到mysql之前对一个句子进行多个复选框

转载 作者:行者123 更新时间:2023-11-30 01:36:12 26 4
gpt4 key购买 nike

我用我的完整编码编辑这个问题

让我在这里发布我的完整代码。

Page1.php

<div id="container">
<div class="box">
<form name="form" method="post" action="userbooking2.php">
<table width="" style="border: 0px solid black" align="center">
<tr>
<td><h2>Book a Room Step 1 - Booking Information</h2></td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="150px" class="titlestyle">Booked by</td>
<td width="400px"><span style="text-transform: uppercase;"><?php echo $_SESSION['SESS_FNAME']; ?></span></td>
</tr>

<tr>
<td class="titlestyle">Title</td>
<td><span class="hint--right" data-hint="Hint : Organization meeting"><input type="text" name="booking_title" id="booking_title" maxlength="50" size="50" /></span></td>
</tr>

<tr>
<td class="titlestyle">Date</td>
<td>From <input type="text" name="booking_start_date" id="booking_start_date"/> to <input type="text" name="booking_end_date" id="booking_end_date"/></td>
</tr>

<tr>
<td class="titlestyle">Time</td>
<td>From <input name="booking_start_time" id="booking_start_time" value="8:00 AM" /> to <input name="booking_end_time" id="booking_end_time" value="8:30 AM"/></td>
</tr>

<tr>
<td class="titlestyle">Room</td>
<td><select name="room_type" id="room_type">
<option value="none">--Select--</option>
<option value="Meeting Room">Meeting Room</option>
<option value="Lecture Room">Lecture Room</option>
<option value="Computer Lab">Computer Lab</option>
</select>
</td>
</tr>

<tr>
<td class="titlestyle">Participant</td>
<td><span class="hint--right" data-hint="Hint : Insert number of participants"><input type="text" name="room_participant" id="room_participant" maxlength="50" size="3" /></span> Persons</td>
</tr>

<tr>
<td class="titlestyle">Equipment</td>
<td><table>
<tr>
<td><input type="checkbox" name="room_facility[]" value="Audio System" />Audio System</td>
<td><input type="checkbox" name="room_facility[]" value="Projector" />Projector</td>
<td><input type="checkbox" name="room_facility[]" value="Video Conferencing" />Video Conferencing</td>
</tr>
</table>
</td>
</tr>

<tr>
<td class="titlestyle">Food & Baverages</td>
<td><table>
<tr>
<td><input type="checkbox" name="room_food[]" value="Breakfast" />Breakfast</td>
<td><input type="checkbox" name="room_food[]" value="Tea Break" />Tea Break</td>
<td><input type="checkbox" name="room_food[]" value="Lunch" />Lunch</td>
</tr>
<tr>
<td><input type="checkbox" name="room_food[]" value="High Tea" />High Tea</td>
<td><input type="checkbox" name="room_food[]" value="Dinner" />Dinner</td>
<td><input type="checkbox" name="room_food[]" value="No" />No, thanks</td>
</tr>
</table>
</td>
</tr>

<tr>
<td class="titlestyle">Additional Info</td>
<td><span class="hint--right" data-hint="Hint : ."><textarea name="booking_desc" id="booking_desc" style="max-width:400px;" rows="4" cols="50"></textarea></span></td>
</tr>
</table>
</td>
</tr>

<tr>
<td colspan="2" align="right"><input type="submit" name="Submit" value="Next" /></td>
</tr>

</table>
</form>
</div>

Page2.php

<?php

//now, let's register our session variables
session_register('fname');
session_register('booking_title');
session_register('booking_start_date');
session_register('booking_end_date');
session_register('booking_start_time');
session_register('booking_end_time');
session_register('room_participant');
session_register('room_type');
session_register('booking_facility');
session_register('booking_food');
session_register('booking_desc');

//finally, let's store our posted values in the session variables
$_SESSION['fname'] = $_SESSION['SESS_FNAME'];
$_SESSION['booking_title'] = $_POST['booking_title'];
$_SESSION['booking_start_date'] = $_POST['booking_start_date'];
$_SESSION['booking_end_date'] = $_POST['booking_end_date'];
$_SESSION['booking_start_time'] = $_POST['booking_start_time'];
$_SESSION['booking_end_time'] = $_POST['booking_end_time'];
$_SESSION['room_participant'] = $_POST['room_participant'];
$_SESSION['room_type'] = $_POST['room_type'];
$_SESSION['room_facility'] = /* WHAT TO SEND HERE? */
$_SESSION['room_food'] = $_POST['room_food'];
$_SESSION['booking_desc'] = $_POST['booking_desc'];?>

// Other form process here

Page3.php

<div id="container">
<div class="box">
<form name="form" method="post" action="">
<table width="" style="border: 0px solid black" align="center">
<tr>
<td><h2>Book a Room Step 3 - Final</h2></td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="150px" class="titlestyle">Booked by</td>
<td width="400px" ><span style="text-transform: uppercase;"><?php echo $_SESSION['SESS_FNAME']; ?></span></td>
</tr>

<tr>
<td class="titlestyle">Title</td>
<td><?php echo $_SESSION['booking_title']; ?></td>
</tr>

<tr>
<td class="titlestyle">Date</td>
<td>From <?php echo $_SESSION['booking_start_date']; ?> to <?php echo $_SESSION['booking_end_date']; ?></td>
</tr>

<tr>
<td class="titlestyle">Time</td>
<td>From <?php echo $_SESSION['booking_start_time']; ?> to <?php echo $_SESSION['booking_end_time']; ?></td>
</tr>

<tr>
<td class="titlestyle">Room</td>
<td><?php echo $_SESSION['room_name']; ?></td>
</tr>

<tr>
<td class="titlestyle">Participant</td>
<td><?php echo $_SESSION['room_participant']; ?> Persons</td>
</tr>

<tr>
<td class="titlestyle">Equipment</td>
<td><?php echo $_SESSION['room_facility']; ?></td>
</tr>

<tr>
<td class="titlestyle">Food & Baverages</td>
<td><?php echo $_SESSION['room_food']; ?></td>
</tr>

<tr>
<td class="titlestyle">Additional Info</td>
<td><?php echo $_SESSION['booking_desc']; ?></td>
</tr>
</table>
</td>
</tr>

<tr>
<td colspan="2" align="right"><input type="submit" name="Submit" value="Submit" /></td>
</tr>

</table>
</form>
</div>

在page3.php中,我想在将其存储到数据库之前查看这种字符串“I book Value1,Value2”

最佳答案

用途:

 $string = implode(', ', isset($_REQUEST['room_facility']) ? $_REQUEST['room_facility'] : array());

echo 'I need ' . $string;

然后像平常一样插入数据库

关于php - 在插入到mysql之前对一个句子进行多个复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16851629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com