How to show record from mysql to radio button and do update

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
umaisagu
Forum Newbie
Posts: 2
Joined: Fri Jan 14, 2005 10:13 am
Contact:

How to show record from mysql to radio button and do update

Post by umaisagu »

I have problem woth my form.. i only can retrieve the textarea field and textbox ..
But how do i retrieve data to the radio button..

Code: Select all

<?php       
mysql_select_db($conn);
$row = mysql_fetch_array(mysql_query("SELECT a.*, b.fullname, c.papertitle FROM evaluation a, tbl_auth_user b, citapapers c where (a.login='$login' and a.paperid=$paperid) and a.login=b.login and a.paperid=c.paperid"));
 
      echo "<tr> 
        <td bordercolor=#999999 bgcolor=#00CC33><font size=-1 face=Arial, Helvetica, sans-serif><b>Reviewer Name</b></font></td>
        <td><font size=-1 face=Arial, Helvetica, sans-serif><b>:</b></font></td>
        <td><font size=-1 face=Arial, Helvetica, sans-serif>$row[fullname]</font></td>
      </tr>"; 
    echo "<tr> 
        <td bordercolor=#999999 bgcolor=#00CC33><font size=-1 face=Arial, Helvetica, sans-serif><b>Paper No.</b></font></td>
        <td><font size=-1 face=Arial, Helvetica, sans-serif><b>:</b></font></td>
        <td><font size=-1 face=Arial, Helvetica, sans-serif><b>$row[paperid]</b></font></td>
      </tr>"; 
      echo "<tr> 
        <td bordercolor=#999999 bgcolor=#00CC33><font size=-1 face=Arial, Helvetica, sans-serif><b>Paper Title</b></font></td>
        <td><font size=-1 face=Arial, Helvetica, sans-serif><b>:</b></font></td>
        <td><font size=-1 face=Arial, Helvetica, sans-serif>$row[papertitle]</font></td>
      </tr>";  
?>

   </font> </table>
    <p><font face="Arial, Helvetica, sans-serif"><br>
      <strong><font size="-1">Instruction: Please select your answer from the 
      following questions.</font></strong> </font>
	  <br>    
    <hr align="center" width="80%" noshade>
    <table cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="style16 style3 style5">1.</td>
    <td colspan="2" valign="top" class="style16 style3 style5">Does the title accurately reflect the content?</td>
    </tr>
  <tr>
    <td width="16" valign="top" class="style16 style3 style5"><p align="center"><strong>&nbsp; </strong></p></td>
[b]    <td width="21" valign="top" class="style16 style3 style5"> <input type="radio" name="q1" value="1" id="q1"></td>[/b]    <td width="726" valign="top" class="style16 style3 style5"><p>Not At All </p></td>
  </tr>

  <tr>
    <td width="22" valign="top" class="style16 style3 style5"><p align="center"><strong>&nbsp; </strong></p></td>
    <td width="20" valign="top" class="style16 style3 style5"><input type="radio" name="q15" value="0" id="q15"></td>
    <td width="721" valign="top" class="style16 style3 style5"><p>No</p></td>
  </tr>
  <tr>
    <td width="22" valign="top" class="style16 style3 style5"><p align="center"><strong>&nbsp; </strong></p></td>
    <td width="20" valign="top" class="style16 style3 style5">&nbsp;</td>
    <td width="721" valign="top" class="style16 style3 style5"></td>
  </tr>
</table>

<tr>
    <td valign="top" class="style12"><p align="left" class="style15 style3 style5">Please give your comments here: </p>      </td>
  </tr>
  <tr>
    <td height="117" valign="top"><p align="left">
      <span class="style10">
      <textarea name="comment" cols="100" rows="5" id="comment" ><?php print "$row[comment]"?></textarea>
      </span><span class="style10">      </span><span class="style13">      </span><span class="style13">      </span>    </p>      
      <blockquote>
        <p>
          	<input type="submit" name="Update" value="Update"> 
        </p>
      </blockquote>
  </form>
can anyone please help me..
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post by ruchit »

generally we use

Code: Select all

$val=($row['radio']=="Value" ? 'checked' : '')
//radio button's declaration
<input type="radio" name="rdbName" value="Value" <?php echo $val; ?> >
umaisagu
Forum Newbie
Posts: 2
Joined: Fri Jan 14, 2005 10:13 am
Contact:

Post by umaisagu »

success code

Code: Select all

<input type="radio" name="q13" value="3" id="q13"  <? if ($row[q13] == 3){ echo "checked"; } ?>
unsuccess code without error but pointing to the wrong radio button(the last option)

Code: Select all

<input type="radio" name="q13" value="Accept_with_no_correction" id="q13"  <? if ($row[q13] = 'Accept_with_no_correction'){ echo "checked"; } ?>
what is the different between

Code: Select all

$row[q13] == 3
and

Code: Select all

$row[q13] = 'Accept_with_no_correction'
consider 1 char
or

Code: Select all

$row[q13] = 'Accept with no correction'
consider as 4 char
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

= is assignment
== is equality
=== is equality and type matching

another bug: you aren't quoting named indices of your arrays, this fires notice errors in the background, slowing your app.
An illustration:

Code: Select all

$someArray[foo]
versus

Code: Select all

$someArray['foo']
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

feyd wrote: === is equality and type matching
ive been wondering this myself for awhile, what does it mean by type matching?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

var_export('1234' == 1234); // true
var_export('1234' === 1234); // false
Post Reply