MySQL Forums
Forum List  »  PHP

Re: Validate a radiobutton and an input text to a while-sql-query?
Posted by: Peter Brawley
Date: January 28, 2014 02:31PM

This snippet from theUsual, www.artfulsoftware.com/theusualReadMe.html, a radiodashboard for getting user's preferred text format, might get you started ...

  $textformat = mysqli_real_escape_string( $conn, $_GET['textformat'] );
  $conn = mysqli_connect(...);
  $avals = array( '0', '1', '2', '3', '4', '5' );
  $aprompts = array( 'as is', 'preformat', 'htmlentities', 'nl2br', 'html_entity_decode', 'nl2br & html_entity_decode' );
  echo "<FORM name='settings' method='post' action='$target'>\n",
       "  <TABLE border='1' bgcolor='#e8e8e8'>\n",
       "    <tr>\n",
       "      <td colspan='2' NOWRAP>&nbsp;<em><strong>Settings</strong></em></td>\n",
       "    </tr>\n";
  echo "    <tr>\n", "      <td>&nbsp;Text column formatting</td>\n";
  radiodashboard( "cbtextformat", $avals, $aprompts, $textformat );
  echo "    </tr>\n";

  ...

function radiodashboard( $group, $aval, $aprompt, $sel ) {
  echo "      <td NOWRAP><table border='0'>\n";
  echo "        <tr>\n";
  for( $i=0; $i < count($aval); $i++ ) {
    $val = $aval[$i];
    echo "          <td align='center'  NOWRAP><INPUT type='radio' name='$group' value='$val'",
         (( $val == $sel ) ? " checked='true'" : "" ), "></td>\n";
  }
  echo "        </tr>\n";
  echo "        <tr>\n";
  for( $i=0; $i < count($aprompt); $i++ ) {
    echo "          <td>&nbsp;", $aprompt[$i], "&nbsp;</td>\n";
  }
  echo "        </tr>\n";
  echo "      </table></td>\n";
}

Options: ReplyQuote


Subject
Written By
Posted
Re: Validate a radiobutton and an input text to a while-sql-query?
January 28, 2014 02:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.