Reply
Showing field value in a php statment
Old 12-04-2008, 04:41 PM Showing field value in a php statment
SKP
SKP's Avatar
Novice Talker

Posts: 14
I have a form that populates related to what was answered in a previous question.
For example, question 1 has a list of 5 brands. I ask what % of each do you use in your business. The next page shows the list of brands that had an answer greater than "0" in question 1 along with their answers and another field to enter the answer to the next question. That is working fine. My problem is that when I go back to that page, I can't bring up the new answers from that page (Q2). They are saving in the MySql database OK but I don't know how to show them in the form field.
Below is my code.
HTML Code:
<tr>
<td width="20">
<?php
$Q1 = $_SESSION['Q1'];
 
$my_ansA = $Q1;
if ($my_ansA > 0) 
{
 echo "Brand A";              
} 
?>
</td>
 
<td width="97">
<div align="center">
<font face="Arial">
<?php
if ($my_ansA > 0) 
{
 echo $row['Q1'];
}
if ($my_ansA > 0) 
{
 echo "%";              
} 
?>
</font>
</div>
</td>
<td>
<div align="right">
 
<?php if ($my_ansA > 0) echo '<input type="text" name="Q2" /> '; ?>
<?php if ($my_ansA > 0) echo "%";?>
</td>
</tr>
I need to somehow show the value of Q2. Below is how I usually do it, but I can't put the php code into a php area.

HTML Code:
<input type="text" name="Q1" value="<?php echo $row['Q1']; ?>"
I've tried this . . .

PHP Code:
<?php if ($my_ansA 0) echo '<input type="text" name="Q2" value="echo $row['Q2']">'?>
but get this error -Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
I'd sure appreciate some help on this. Thanks!
SKP is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 12-04-2008, 05:11 PM Re: Showing field value in a php statment
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
PHP Code:
<?php if ($my_ansA 0) echo '<input type="text" name="Q2" value="'.row['Q2'].'">'?>
... would be my suggestion to fix that error.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 12-05-2008, 09:18 AM Re: Showing field value in a php statment
SKP
SKP's Avatar
Novice Talker

Posts: 14
Insensus - using your suggestion I get this error:
Parse error: syntax error, unexpected '[', expecting ',' or ';'

<?php ($helpfull<0)?$talkupation++ : 'not yet';?>
SKP is offline
Reply With Quote
View Public Profile
 
Old 12-05-2008, 09:29 AM Re: Showing field value in a php statment
SKP
SKP's Avatar
Novice Talker

Posts: 14
Insensus - I kept working at it and just figured out I was only missing the $ from your suggestion. Thanks. I've added to your talkupation.
SKP is offline
Reply With Quote
View Public Profile
 
Old 12-06-2008, 08:48 AM Re: Showing field value in a php statment
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Oops, my bad.
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Showing field value in a php statment
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11116 seconds with 12 queries