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? 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 ?>"> 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. 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>'; ?> 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. 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
Archived
This topic is now archived and is closed to further replies.