[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

add radiobutton button to a list of template

Posted on 2007-10-01
5
Medium Priority
?
272 Views
Last Modified: 2008-09-22
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
Comment
Question by:usmbay
  • 2
3 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 19991508
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
 

Author Comment

by:usmbay
ID: 19991765
I will get the value from the select statment
" SELECT tfr.isDefault "
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 19991881
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question