Javascript 基于mysql时间戳的时间戳禁用输入字段
我正在为足球比赛/杯赛编写一个赌博游戏。在本游戏中,用户可以在比赛开始前5分钟以某种形式下注。在该时间点之后,应禁用/灰显字段,使其仍显示输入的值,但不再可编辑 如何根据Javascript 基于mysql时间戳的时间戳禁用输入字段,javascript,php,mysql,Javascript,Php,Mysql,我正在为足球比赛/杯赛编写一个赌博游戏。在本游戏中,用户可以在比赛开始前5分钟以某种形式下注。在该时间点之后,应禁用/灰显字段,使其仍显示输入的值,但不再可编辑 如何根据时间和日期(为mysql表中的每个游戏保存)自动禁用这些“分数输入字段” 如果您需要查看更多代码或需要有关mysql表的更多信息,请询问 SQL查询与表 $records = mysqli_query($conn, " SELECT sp.spiel_id, DATE_FORMAT(sp.
时间
和日期
(为mysql表中的每个游戏保存)自动禁用这些“分数输入字段”
如果您需要查看更多代码或需要有关mysql表的更多信息,请询问
SQL查询与表
$records = mysqli_query($conn, "
SELECT
sp.spiel_id,
DATE_FORMAT(sp.datum, \"%d.%m.%Y\") AS datum,
DATE_FORMAT(sp.zeit, \"%H:%i\") AS zeit,
sp.heimteam_id,
sp.gastteam_id,
sp.tore_heimteam,
sp.tore_gastteam,
ht.teamname AS heimteam_name,
at.teamname AS gastteam_name,
t.match_id,
t.user_id,
t.tipp_heim,
t.tipp_gast,
t.punkte_tipp,
u.user_id,
u.username
FROM
spielplan sp
LEFT JOIN mannschaften ht
ON sp.heimteam_id = ht.mannschafts_id
LEFT JOIN mannschaften at
ON sp.gastteam_id = at.mannschafts_id
LEFT JOIN tipps t
ON sp.spiel_id = t.match_id
LEFT JOIN users u
ON t.user_id = u.user_id
WHERE
username = '".$_SESSION["username"]."'
ORDER BY
spiel_id ASC
");
while($fields = mysqli_fetch_assoc($records)) {
?>
<tr>
<input type="hidden" name="spiel_ids[]" value="<?php echo $fields["spiel_id"] ?>">
<td><?php echo $fields["datum"] ?></td>
<td><?php echo $fields["zeit"] ?></td>
<td><?php echo $fields["heimteam_name"] ?></td>
<td><?php echo $fields["tore_heimteam"] ?></td>
<td>:</td>
<td><?php echo $fields["tore_gastteam"] ?></td>
<td><?php echo $fields["gastteam_name"] ?></td>
<input type="hidden" name="user_ids[]" value="<?php echo $fields["user_id"] ?>">
<td><input type="tel" maxlength="2" size="5" name="tipps_heim[]" value="<?php echo $fields["tipp_heim"] ?>"></td>
<td><input type="tel" maxlength="2" size="5" name="tipps_gast[]" value="<?php echo $fields["tipp_gast"] ?>"></td>
<td><?php echo $fields["punkte_tipp"] ?></td>
</tr>
<?php
}
?>
$records=mysqli\u查询($conn,”
挑选
sp.spiel_id,
日期格式(sp.datum,\%d.%m.%Y\)作为基准,
日期格式(sp.zeit,\%H:%i\)为zeit,
sp.heimteam_id,
sp.gastteam_id,
sp.tore_heimteam,
sp.tore_gastteam,
ht.teamname作为heimteam_名称,
at.teamname作为团队名称,
t、 匹配id,
t、 用户id,
t、 蒂普海姆,
t、 蒂普加斯特,
t、 蓬克特提普,
u、 用户id,
u、 用户名
从…起
斯皮尔普兰
左连接mannschaften ht
在sp.heimteam_id=ht.mannschafts_id上
左加入mannschaften在
在sp.gastteam_id=at.mannschafts_id上
左连接tipps t
在sp.spiel\u id=t.match\u id上
左加入用户u
在t.user\u id=u.user\u id上
哪里
用户名=“$\u会话[“用户名”]。”
订购人
斯皮尔迪德ASC
");
而($fields=mysqli\u fetch\u assoc($records)){
?>
我不建议您这样做,但您可以尝试:
例如,您要禁用的是您的字段
<input name="spiel_ids[]" value="<?php echo $fields["spiel_id"] ?>">
sql、js和php在一个文件中…我不知道如何实现这一点。我唯一的想法是使用javascript在“匹配时间”向输入字段添加readonly
减5分钟。你为什么不重新编译这个?对我来说似乎很合理。首先想到的是它太容易作弊。一行代码再次启用输入,因此你仍然需要添加代码来检查下注处理脚本中是否仍然允许下注。删除输入并替换它可能更安全y是一个文本字段。我不会在一个文件中使用sql和php重新命名。
<?php
$disabled = "";
//you check if you date is in future, then you disable field
if (date('Y-m-d', strtotime($fields['datum'])) > date('Y-m-d')) {
$disabled = "disabled='disabled'";
} ?>
<input <?php echo $disabled ?> name="spiel_ids[]" value="<?php echo $fields["spiel_id"] ?>">