gpt4 book ai didi

php - 如何获取表单提交时的 cID 值

转载 作者:行者123 更新时间:2023-11-29 14:46:41 25 4
gpt4 key购买 nike

<img src="img/commentBelowIcon.png" width="26" height="26" class="left" /><h3>Add Comment</h3>
<?php if(!empty($_GET['pID'])) $the_pID = mysql_real_escape_string($_GET['pID']); $thedt = date("Y-m-d");?>
<form action="inc/q/prof.php?pID=<?php echo $the_pID; ?>" method="post" id="addition">
<div class="field required">
<select id="courseInfoDD" class="verifyText" name="courseInfoDD" tabindex="1">
<option disabled="disabled">Course...</option>
<?php while($row3 = $sth3->fetch(PDO::FETCH_ASSOC))
{echo "<option value=". $row3['cID'] . ">" .$row3['prefix']." ".$row3['code']."</option>";}
?>
</select>
</div>
<div class="field required">
<select id="commQuarter" class="verifyText" name="commQuarter" tabindex="2" >
<option disabled="disabled">Quarter...</option>
<option value="Fall">Fall</option>
<option value="Winter">Winter</option>
<option value="Spring">Spring</option>
<option value="Summer">Summer</option>
</select>
</div>
<div class="field required">
<select id="commYr" name="commYr" class="verifyText" tabindex="3">
<option disabled="disabled">Year...</option>
<?php $startdate = 2000;$enddate = date("Y");$years = range ($startdate,$enddate);foreach($years as $year){echo "<option value='$year'>$year</option>";}?>
</select>
</div>

<div class="field required">
<select id="commExp" class="verifyText" name="commExp" tabindex="4" >
<option disabled="disabled">Overall Experience</option>
<option value="1">Positive</option>
<option value="2">Neutral</option>
<option value="3">Negative</option>
</select>
</div>


<div class="field required">
<textarea type="text" id="addComment" class="verifyText" name="addComment" tabindex="5" value="Enter comment"></textarea></div>
<input type="hidden" name="dt" value="<?php echo $thedt; ?>" />
<input type="hidden" name="pID" value="<?php echo $the_pID; ?>" />
<div class="field required">
Accept Terms?
Yes:&nbsp;<input type="radio" name="terms" value="Yes" id="accepting" tabindex="6" />
No:&nbsp;<input type="radio" name="terms" value="No" id="accepting" tabindex="7" />
</div>
<p class="iferror">Please correct the above.</p>

<input type="submit" name="submit" id="submit" tabindex="8" />
</form>

</div>
</div>

<?php // Get select box options
$pID3 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
$pdo3 = new PDO('mysql:host=###;dbname=###', $u, $p);
$pdo3->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth3 = $pdo3->prepare('
SELECT pID, C.cID, C.prefix, C.code
FROM Department D, Course C, Professor P
WHERE pID = ?
AND D.dID = C.dID
AND D.dID = P.dID;
');
$sth3->execute(array(
$pID3
));
?>

我收到的提交数据如下所示: img

如何获取要提交的 cID 值?有人可以告诉我需要在 php 中添加什么吗?

谢谢

最佳答案

执行

$cid = mysql_insert_id();

之后

$sth3->execute(array(
$pID3
));

链接 http://php.net/manual/en/function.mysql-insert-id.php

希望有帮助

:)

关于php - 如何获取表单提交时的 cID 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6838395/

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