Retrving data from database to form

Reply

Join Date: Aug 2008
Posts: 3
Reputation: nrvuppula is an unknown quantity at this point 
Solved Threads: 0
nrvuppula nrvuppula is offline Offline
Newbie Poster

Retrving data from database to form

 
0
  #1
Sep 9th, 2008
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
  1. <?php
  2. global $Ans1, $Ans2, $Ans3, $Ans4, $Ans5, $comments;
  3.  
  4. $connect = mysql_connect("Localhost", "root", "") or die ("I am unable to conect with database because of".mysql_error());
  5.  
  6. $selectdb = mysql_select_db("moodledb") or die("I can't select the database because of".mysql_error());
  7.  
  8. $Join = "SELECT `mdl_al_sessionfeedback`.`sessionid`, `mdl_al_sessionfeedback`.`ans1`, `mdl_al_sessionfeedback`.`ans2`,
  9.  
  10. `mdl_al_sessionfeedback`.`ans3`, `mdl_al_sessionfeedback`.`ans4`,`mdl_al_sessionfeedback`.`ans5`,
  11.  
  12. `mdl_al_sessionfeedback`.`comments` FROM `mdl_al_sessionfeedback`, `mdl_al_sessions` WHERE (`mdl_al_sessionfeedback`.`sessionid` =
  13. `mdl_al_sessions`.`alsessioncode`) ";
  14.  
  15. $result = mysql_query($Join) or die("Unable to execute the join query because of:".mysql_error());
  16.  
  17. $row = mysql_fetch_assoc($result);
  18.  
  19. $num = mysql_num_rows($result);
  20.  
  21. for($i=0; $i<$num; $i++)
  22. {
  23. $Ans1 = mysql_result($result,$i,"ans1");
  24.  
  25. $Ans2 = mysql_result($result,$i,"ans2");
  26.  
  27. $Ans3 = mysql_result($result,$i,"ans3");
  28.  
  29. $Ans4 = mysql_result($result,$i,"ans4");
  30.  
  31. $Ans5 = mysql_result($result,$i,"ans5");
  32.  
  33. $comments = mysql_result($result,$i,"comments");
  34.  
  35. echo $comments;
  36. }
  37. echo "<textarea name='txtComments' rows='2' cols='20' id='txtComments' value = '<?php $comments ?>'></textarea>";
  38. ?>
Last edited by cscgal; Sep 9th, 2008 at 11:50 am. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,071
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Retrving data from database to form

 
0
  #2
Sep 9th, 2008
i think the last line is not correct...
try instead:
  1. echo "<textarea name='txtComments' rows='2' cols='20' id='txtComments'><?php echo $comments ?></textarea>";
textarea doesn't have value attribute...
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 3
Reputation: nrvuppula is an unknown quantity at this point 
Solved Threads: 0
nrvuppula nrvuppula is offline Offline
Newbie Poster

Re: Retrving data from database to form

 
0
  #3
Sep 9th, 2008
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
Attached Images
File Type: jpg form.JPG (109.5 KB, 5 views)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC