Jump to content

display hidden field


Marcos01

Recommended Posts

Hello, I have a form on 1 page which pulls questions from a database.

 

I would like to display the hidden field. I dont know if i use the hidden field correctly. Thanks for your help

 

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" value="">';

$query1="Select * from formquestions where pagina=$currentpage order by questionnumber";

$result1=mysql_query( $query1) or die("question query certainly didn't work");
while ($row=mysql_fetch_array($result1))
{
$query2="Select * from formresponse where pagina=$currentpage and questionnumber = ".$row[questionnumber]." order by responsenum";


$result2=mysql_query( $query2) or die("Response Query certainly didn't work");
while ($row2=mysql_fetch_array($result2))
	{
	echo '<input type="radio" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'" />'.$row2['responsetext'].'<br />';
	}

echo '<br />';
}

//hidden values per page

echo '<input type="hidden" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'">';

//===========================================================
echo '<input type="submit" name="pageminus" value="previous">';
echo '<input type="submit" name="pageplus" value="next">';
echo '<input type="hidden" name="camefrom" value="'.$currentpage.'">';
echo '</form>';

Link to comment
https://forums.phpfreaks.com/topic/130864-display-hidden-field/
Share on other sites

The form I use displays 2 to 4 questions max at the time. After I hit next,

A new set of questions is displayed. Above that I would like to display the previous filled out data.

 

So if this line of code is correctly:

 

echo '<input type="hidden" name="'.$row['questionnumber'].$row['page'].'" value="'.$row2['responsetext'].'">';

 

What would the code be to print/display it?

 

Sorry if I wasn't clear enough.

 

Thank you all for your help

Link to comment
https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-679267
Share on other sites

When you assign the hidden field name assign that same value to a double array.  Array[$Q_num][$page].  Before you submit you need to create another hidden field and pass this array through.  So when you submit the page to itself you can get the values/questions with $_POST from the array.

 

Maybe someone has a better idea?

Link to comment
https://forums.phpfreaks.com/topic/130864-display-hidden-field/#findComment-681214
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.