Jump to content

Recommended Posts

Hi, I'm very new at PHP and SQL integration. I have a form that web users are to fill in, 4 questions that have a numerical answer, and 4  text answers that they will type to correlate with the numerical answers. All that goes off to the database I set up fine. I then want to display the numerical results in a table and be able to click on the boxes to bring up the appropriate text response in pop-ups.I can get my table to generate correctly as forms get filled in with the correct numbers, but the pop-ups show only the first, or last text answer given depending on where I put in the PHP code. I'll copy in my code below if it's too much please let me know. Please could someone give me a point in the right direction, or even if this is possible to do or not?

$query="SELECT * FROM Test1";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<div class="form">
<div class="header1">
<br/>Results
</div>
<div class="wtmmain1">
<table id="results1" class="resultstable">
<tr>
<td class="tablebox1" >Talking</td>
<td class="tablebox1">Writing</td>
<td class="tablebox1">Distance</td>
<td class="tablebox1">Looking</td>

</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"Training1");
$f2=mysql_result($result,$i,"Training2");
$f3=mysql_result($result,$i,"Training3");
$f4=mysql_result($result,$i,"Training4");
?>
<tr>
<td class="tablebox2" onclick="FP_changeProp(/*id*/'text1',0,'style.visibility','visible')"><?php echo $f1; ?></td>
<td class="tablebox2" onclick="FP_changeProp(/*id*/'text2',0,'style.visibility','visible')"><?php echo $f2; ?></td>
<td class="tablebox2" onclick="FP_changeProp(/*id*/'text3',0,'style.visibility','visible')"><?php echo $f3; ?></td>
<td class="tablebox2" onclick="FP_changeProp(/*id*/'text4',0,'style.visibility','visible')"><?php echo $f4; ?></td>

</tr>

<?php
$i++;
}
?>
</table>

<?php
$i=0;
while ($i < $num) {

$f5=mysql_result($result,$i,"Text1");
$f6=mysql_result($result,$i,"Text2");
$f7=mysql_result($result,$i,"Text3");
$f8=mysql_result($result,$i,"Text4");
?>

<div id="text1" class="textpopup1" onclick="FP_changeProp(/*id*/'text1',0,'style.visibility','hidden')"><?php echo $f5; ?></div>
<div id="text2" class="textpopup1" onclick="FP_changeProp(/*id*/'text2',0,'style.visibility','hidden')"><?php echo $f6; ?></div>
<div id="text3" class="textpopup1" onclick="FP_changeProp(/*id*/'text3',0,'style.visibility','hidden')"><?php echo $f7; ?></div>
<div id="text4" class="textpopup1" onclick="FP_changeProp(/*id*/'text4',0,'style.visibility','hidden')"><?php echo $f8; ?></div>

<?php
$i++;
}
?>


</div>

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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