Siggles Posted February 7, 2008 Share Posted February 7, 2008 Any ideas why this doesn't work... $result3 = mysql_query("SELECT dateplayed, opponent, homeaway, id FROM fixtures WHERE id NOT IN (SELECT id FROM predictions WHERE username = '$session->username') AND NOW() < dateplayed ORDER BY dateplayed DESC"); while($row = mysql_fetch_array($result3)) { echo "<tr><td>".date('d/m/y',strtotime($row['dateplayed']))."</td>"; echo "<td>".date('G:ia',strtotime($row['dateplayed']))."</td>"; echo "<td align=\"center\">(".$row['homeaway'].")</td>"; echo "<td>".$row['opponent']."</td>"; $cid=$row['id']; echo "<td>"; ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> <input type="text" name="resultmfc" size="1"></td><td> <input type="text" name="resultother" size="1"></td> <td> <input type="submit" name="submit" value="Add!"></td> <input type="hidden" name="opt" value="addprediction" /> <input type="hidden" name="id" value="<? $cid ?>"> </form> <? echo "</tr>"; } echo "</table>"; } ?> then later on <? //NEED ID, USERNAME, RESULTMFC, RESULTOTHER //SQL FOR ADDING PREDICTION FOR EXISTING FIXTURE switch($_POST['opt']) { case "addprediction": $pid=$_POST['id']; $pusername=$session->username; $presultmfc=$_POST['resultmfc']; $presultother=$_POST['resultother']; mysql_query("INSERT INTO predictions (username, id, resultmfc, resultother) VALUES ('$pusername', '$pid', '$presultmfc', '$presultother')"); echo "<table align=\"center\" style=\"border:#666666 dashed 1px\"> <tr><td>Prediction inserted successfully!</td></tr></table>"; break; } ?> Everything is passed and inserted into the dbase other than the id? Quote Link to comment https://forums.phpfreaks.com/topic/89926-solved-passing-hidden-varaible-help/ Share on other sites More sharing options...
toplay Posted February 7, 2008 Share Posted February 7, 2008 Change: <input type="hidden" name="id" value="<? $cid ?>"> To this: <input type="hidden" name="id" value="<? echo $cid; ?>"> or short notation (depending on server setting allowing it): <input type="hidden" name="id" value="<?= $cid ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/89926-solved-passing-hidden-varaible-help/#findComment-461006 Share on other sites More sharing options...
aschk Posted February 7, 2008 Share Posted February 7, 2008 A handy utility to see what variables are you POST'ing is the print_r() function. e.g. echo "<pre>"; print_r($_POST); echo "</pre>"; This way you can see ALL the POST variables that are being passed to the page in question and have them printed out in a nice format for you to see while debugging. Quote Link to comment https://forums.phpfreaks.com/topic/89926-solved-passing-hidden-varaible-help/#findComment-461016 Share on other sites More sharing options...
toplay Posted February 7, 2008 Share Posted February 7, 2008 Yes, good advice aschk. FYI: Instead of three lines, it can be all on one line: <?php echo '<pre>', print_r($_POST, TRUE), '</pre>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/89926-solved-passing-hidden-varaible-help/#findComment-461030 Share on other sites More sharing options...
Siggles Posted February 7, 2008 Author Share Posted February 7, 2008 Thans guys, works. Quote Link to comment https://forums.phpfreaks.com/topic/89926-solved-passing-hidden-varaible-help/#findComment-461114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.