Jump to content

Recommended Posts

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

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  ?>">

 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.