woodplease Posted February 2, 2010 Share Posted February 2, 2010 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 More sharing options...
jammesz Posted February 2, 2010 Share Posted February 2, 2010 Theres a typo in your php. Before: <input type="hidden" name="question" value="'.$question'"> //i want the ..... After: <input type="hidden" name="question" value="'.$question.'"> //i want the ..... Insert a dot after $question Link to comment https://forums.phpfreaks.com/topic/190655-getting-a-value-from-a-query/#findComment-1005471 Share on other sites More sharing options...
woodplease Posted February 2, 2010 Author Share Posted February 2, 2010 i've corrected that, but when i view the source, i get <form method="post" action ="editquestions.php"> <input type="hidden" name="quizno" value="1"> <input type="hidden" name="question" value=""> the value is empty, and i dont know why Link to comment https://forums.phpfreaks.com/topic/190655-getting-a-value-from-a-query/#findComment-1005490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.