Jump to content

getting a value from a query


woodplease

Recommended Posts

i'm trying to get a use a value from a query to use in an input type  tag, but i'm not sure how, can anyone help?

 

this is what i have so far

 

<?php
$id = $_GET['id'];
$query = "SELECT * FROM questions WHERE quizref = " .$id ;
$question = 'questionno';
$result2 = pg_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = pg_num_rows($result2);

?>

<form method="post" action ="editquestions.php">
<?PHP

for($i = 1; $i <= $numofrows; $i++) {
$row = pg_fetch_array($result2); //get a row from our result set

echo '<input type="hidden" name="quizno" value="'.$id.'">
	<input type="hidden" name="question" value="'.$question'"> //i want the value to be from the results of the query above
<br/><p>Question '.$row['questionno'].': ' .$row['question'].' <input type="Submit"  value="EDIT">  <br/><br/></p>

 

when i view the source, the input tag has a no value.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/190655-getting-a-value-from-a-query/
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.