• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

add radiobutton button to a list of template

here a function to display a list of template, and I want to add a radiobutton beside each template to mark it as a defualt

function getListTemplate()
{
      $query = "SELECT tfr.titre as titrefr, ten.titre as titreen, tfr.corps as corpsfr, ten.corps as corpsen, tfr.id as idTemplatefr, ten.id as idTemplateen FROM template as tfr, template as ten WHERE tfr.deleted='n'  AND tfr.idHotel = ".$_SESSION["SES_idHotel"]." AND tfr.idLanguage = 2 AND ten.idLanguage = 1";
      $res = shoot_query($query);

      $i=1;
      while ($row = mysql_fetch_assoc($res))
      {
            $onclick = "parent.ifrCorrespondance.location.href = 'form.php?action=".CORRESPONDANCE_TEMPLATE."&id=".$row["idTemplatefr"]."';
                              parent.ifrTitle.location.href = 'form.php?action=".CORRESPONDANCE_TITLE."&titre=".CORRESPONDANCE_TITLE_TEMPLATE."';
                              parent.document.getElementById('ifrHeader').style.display = 'none';
                              parent.document.getElementById('divResultat').style.display = 'none';
                              parent.document.getElementById('ifrList').style.display = 'none';
                              parent.document.getElementById('ifrLegend').style.display = 'none';
                              parent.document.getElementById('ifrCorrespondance').style.display = 'inline';";
            $color       = ($i%2==0) ? "#F2F2F2" : "white";
            $strFR  = ($row["titrefr"] == "") ?
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\" height=\"100%\"><TD width=\"100%\" align=\"center\"><B>".LB_EMPTY2."</B></TD></TR></TABLE>" :
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\"><TD width=\"2%\">&nbsp;</TD><TD>&nbsp;</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD><B>".$row["titrefr"]."</B></TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD>".$row["corpsfr"]."</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD colspan=\"2\">&nbsp;</TD></TR></TABLE>";

            $strEN  = ($row["titreen"] == "") ?
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\" height=\"100%\"><TD width=\"100%\" align=\"center\"><B>".LB_EMPTY2."</B></TD></TR></TABLE>" :
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\"><TD width=\"2%\">&nbsp;</TD><TD>&nbsp;</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD><B>".$row["titreen"]."</B></TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD>".$row["corpsen"]."</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD colspan=\"2\">&nbsp;</TD></TR></TABLE>";

            $str   .= "<TR bgcolor=\"$color\" onclick=\"$onclick\" style=\"cursor: hand;\"><TD width=\"50%\" style=\"border-right: 1 solid silver; border-bottom: 1 solid silver;\" valign=\"middle\">".$strFR."</TD>".
                          "<TD valign=\"middle\" style=\"border-bottom: 1 solid silver;\">".$strEN."</TD></TR>";
            $i++;
      }

      return "<TABLE width=\"100%\" cellpadding=\"0\">$str</TABLE>";
}
0
usmbay
Asked:
usmbay
  • 2
1 Solution
 
Steve BinkCommented:
How do you determine if the record is a default or not?  Will the radio button be expected to do anything other than indicate a default?  (for example, to set a default...)
0
 
usmbayAuthor Commented:
I will get the value from the select statment
" SELECT tfr.isDefault "
0
 
Steve BinkCommented:
If you're not using to allow setting a default, the radio button is superfluous.  You could just as easily create a text tag that displays only on the appropriate records.  The basics are to examine the field in each record.  If yes, print it, if not, don't.  An example:

<?
$query = "SELECT field1,field2 from mytable";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result)) {
  echo "field1={$row['field1']} ";
  if ($row['field2'] == 'myvalue') { echo "<b>DEFAULT</b>"; }
  echo "<br />";
}
?>

To use a radio button instead, just change the second echo to reflect the HTML you would like to print out.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now