DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   Retrving data from database to form (http://www.daniweb.com/forums/thread144804.html)

nrvuppula Sep 9th, 2008 5:16 am
Retrving data from database to form
 
Hi

Can any one help me

I have the data in the database and i retrive it using mysql_fetch_assoc using while loop and i am trying to display it it on HTML form it is not displayed can any one help me

U can find my script
<?php
global $Ans1, $Ans2, $Ans3, $Ans4, $Ans5, $comments;

$connect = mysql_connect("Localhost", "root", "") or die ("I am unable to conect with database because of".mysql_error());

$selectdb = mysql_select_db("moodledb") or die("I can't select the database because of".mysql_error());

$Join = "SELECT `mdl_al_sessionfeedback`.`sessionid`, `mdl_al_sessionfeedback`.`ans1`, `mdl_al_sessionfeedback`.`ans2`,

`mdl_al_sessionfeedback`.`ans3`, `mdl_al_sessionfeedback`.`ans4`,`mdl_al_sessionfeedback`.`ans5`,

`mdl_al_sessionfeedback`.`comments` FROM `mdl_al_sessionfeedback`, `mdl_al_sessions`  WHERE (`mdl_al_sessionfeedback`.`sessionid` =
`mdl_al_sessions`.`alsessioncode`) ";

$result = mysql_query($Join) or die("Unable to execute the join query because of:".mysql_error());

$row = mysql_fetch_assoc($result);

$num = mysql_num_rows($result);

for($i=0; $i<$num; $i++)
        {
        $Ans1  = mysql_result($result,$i,"ans1");
               
        $Ans2 = mysql_result($result,$i,"ans2");
               
                $Ans3  = mysql_result($result,$i,"ans3");
               
        $Ans4 = mysql_result($result,$i,"ans4");
               
                $Ans5  = mysql_result($result,$i,"ans5");
               
        $comments = mysql_result($result,$i,"comments");
               
                echo $comments;
                }
                echo "<textarea name='txtComments' rows='2' cols='20' id='txtComments' value = '<?php $comments ?>'></textarea>";
?>

Shanti Chepuru Sep 9th, 2008 7:31 am
Re: Retrving data from database to form
 
i think the last line is not correct...
try instead:
echo "<textarea name='txtComments' rows='2' cols='20' id='txtComments'><?php  echo $comments ?></textarea>";
textarea doesn't have value attribute...

nrvuppula Sep 9th, 2008 7:49 am
Re: Retrving data from database to form
 
1 Attachment(s)
Hi shanti


Here what my requirement is by executing the above sql query i got total 108 rersults

and i want display the comments one for one session and 5 Radio button values which is also featched from the same table and i have changed the lost line

printf("<textarea rows=4 cols=20>%s</textarea>\n<br>", $comments);

for every i got one text box along with the comment

and i am attaching my final form also

can u help me

in the form it display default radio button value instead of orginal values


All times are GMT -4. The time now is 5:08 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC