How do I get value of cID on form submission
<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>
开发者_如何学JAVA <?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: <input type="radio" name="terms" value="Yes" id="accepting" tabindex="6" />
No: <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
));
?>
I get submitted data that looks like this:
How do I get a value for cID
to submit as well? Can someone show me what I need to put in my php?
Thanks
execute
$cid = mysql_insert_id();
after
$sth3->execute(array(
$pID3
));
link http://php.net/manual/en/function.mysql-insert-id.php
hope helps
:)
精彩评论