PHP - Help With Changing <select> Into Input Chceckbox
Hi, at the beginning i would like to apologize for my English if there will be some mistakes .
I heve proble with changing standard <select> code with <options> to normal input with check box( it's very annoying when you need to press ctrl to select more then one options, that's why i wish to have check box This is original code with <select> <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); /** * Paramater search for phpShop * @author Zdenek Dvorak (zdenek.dvorak@seznam.cz) * * @version $Id: shop.parameter_search_form.php 1452 2008-07-08 17:21:42Z soeren_nb $ * @package VirtueMart * @subpackage html * @copyright Copyright (C) 2004-2008 soeren - All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ $q = "SELECT * FROM #__{vm}_product_type "; $q .= "WHERE product_type_id='$product_type_id' "; $q .= "AND product_type_publish='Y'"; $db->query($q); $browsepage = $db->f("product_type_browsepage"); $vm_mainframe->setPageTitle( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $pathway[] = $vm_mainframe->vmPathwayItem( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $vm_mainframe->vmAppendPathway($pathway); echo "<h2>".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH')."</h2>"; if (!$db->next_record()) { // There is no published Product Type echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_BAD_PRODUCT_TYPE'); } else { echo "<table width=\"100%\" border=\"0\">\n<tr><td width=\"40%\">"; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IN_CATEGORY').": ".$db->f("product_type_name"); // Reset form echo "</td><td align=\"center\">"; echo "<form action=\"".$sess->url( $mm_action_url.basename($_SERVER['PHP_SELF']). "?page=shop.parameter_search_form&product_type_id=". $product_type_id ). "\" method=\"get\" name=\"reset\">\n"; echo "<input type=\"submit\" class=\"button\" name=\"reset\" value=\""; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_RESET_FORM') ."\">\n</form>"; echo "</td><td width=\"40%\"> </td></tr></table>\n"; ?> <form action="<?php echo URL ?>index.php" method="get" name="attr_search"> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="page" value="shop.browse" /> <input type="hidden" name="product_type_id" value="<?php echo $product_type_id ?>" /> <input type="hidden" name="Itemid" value="<?php echo $sess->getShopItemid() ?>" /> <br /> <?php $q = "SELECT * FROM #__{vm}_product_type_parameter "; $q .= "WHERE product_type_id=$product_type_id "; $q .= "ORDER BY parameter_list_order"; $db->query($q); echo "dupa1\n"; ?> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <?php /******************************************************** ** BrowsePage - You can use your tepmlate for searching: ** 1) write file with html table (without tags <table> and </table>) and ** take its name into variable browsepage in Product Type ** 2) You can use this page from tag <!-- Default list of parameters - BEGIN --> to ** tag <!-- Default list of parameters - END --> and changed it. ** 3) tag {product_type_<product_type_id>_<parameter_name>} will be replaced input field, or select field ** tag {product_type_<product_type_id>_<parameter_name>_comp} will be replaced comparison ** for this parameter. It is important for correct SQL question. ** tag {product_type_<product_type_id>_<parameter_name>_value} will be replaced value for this ** parameter (when you click on button "Change Parametes" in Browse page). ********************************************************/ if (!empty($browsepage)) { // show browsepage /** * Read the template file into a String variable. * * function read_file( $file, $defaultfile='') ***/ $template = read_file( PAGEPATH."templates/".$browsepage.".php"); echo "dupa2\n"; //$template = str_replace( "{product_type_id}", $product_type_id, $template ); // If you need this, use it... while ($db->next_record()) { $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $parameter_values=$db->f("parameter_values"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); $parameter_type = $db->f("parameter_type"); // Replace parameter value $template = str_replace( "{".$item_name."_value}", $get_item_value, $template ); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET $comp = "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; $comp .= "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."</option>\n"; $comp .= "<option value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."</option>\n"; $comp .= "</select></td>"; } else { // type: all other // Multiple section List of values - no comparison $comp = "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $comp = "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"")."><</option>\n"; $comp .= "<option value=\"le\"".(($get_item_value_comp=="le")?" selected":"")."><=</option>\n"; $comp .= "<option value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=</option>\n"; $comp .= "<option value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">>=</option>\n"; $comp .= "<option value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">></option>\n"; $comp .= "<option value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"")."><></option>\n"; $comp .= "</select>\n"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; $comp .= "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; $comp .= "<option value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n"; $comp .= "</select>"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; $comp .= "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; $comp .= "</select></td>"; } } // Relace parameter comparison $template = str_replace( "{".$item_name."_comp}", $comp, $template ); // Parameter field if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); $attr = "<select class=\"inputbox\" name=\"$item_name"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); $attr .= "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."</option>\n"; } } else { $attr .= "\">\n"; $attr .= "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n"; foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."</option>\n"; } } $attr .= "</select>"; } else { // Input field switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text $attr = "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } // Relace parameter $template = str_replace( "{".$item_name."}", $attr, $template ); } echo $template; } else { // show default list of parameters echo "\ndupa3\n<!-- Default list of parameters - BEGIN -->\n"; while ($db->next_record()) { $parameter_type = $db->f("parameter_type"); if ($parameter_type!="B") { echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $db->f("parameter_label"); if ($db->f("parameter_description")) { echo " "; echo mm_ToolTip($db->f("parameter_description"),$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION')); } echo " :</strong></div>\n </td>\n"; $parameter_values=$db->f("parameter_values"); $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."</option>\n"; echo "<option value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."</option>\n"; echo "</select></td>"; } else { // type: all other // Multiple section List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n</td>\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"")."><</option>\n"; echo "<option value=\"le\"".(($get_item_value_comp=="le")?" selected":"")."><=</option>\n"; echo "<option value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=</option>\n"; echo "<option value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">>=</option>\n"; echo "<option value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">></option>\n"; echo "<option value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"")."><></option>\n"; echo "</select></td>"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; echo "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; echo "<option value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n"; echo "</select></td>"; break; case "V": // Multiple Value echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"find_in_set\" />\n</td>\n"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; echo "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; echo "</select></td>"; } } if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); echo "<td width=\"55%\" height=\"2\" valign=\"top\">\n"; echo "<select class=\"inputbox\" name=\"$item_name"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); echo "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { echo "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."</option>\n"; } } else { echo "\">\n"; echo "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n"; foreach($fields as $field) { echo "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."</option>\n"; } } echo "</select>"; } else { // Input field echo "<td width=\"55%\" height=\"2\">\n"; switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text echo "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } echo " ".$db->f("parameter_unit"); switch( $parameter_type ) { case "D": // Date & Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT')." "; echo $VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; case "A": // Date echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT').")"; break; case "M": // Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; } } else { // Break line (type == "B") echo "<tr>\n <td colspan=\"3\" height=\"2\" ><hr>"; } echo " </td>\n</tr>"; } echo "\n<!-- Default list of parameters - END -->\n\n"; } // Add search according to price: $item_name = "price"; $get_item_value = vmGet($_REQUEST, $item_name, ""); $item_name = "price_from"; $get_item_value_from = vmGet($_REQUEST, $item_name, ""); $item_name = "price_to"; $get_item_value_to = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $VM_LANG->_('PHPSHOP_CART_PRICE')." :</strong></div>\n </td>\n"; // input text echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_from\" value=\"$get_item_value_from\" size=\"20\" />"; echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_to\" value=\"$get_item_value_to\" size=\"20\" /></td>\n</tr>"; // Search Button ?> <tr><td colspan="3" height="2" > </td></tr> <tr><td colspan="3" height="2" ><div align="center"> <input type="submit" class="button" name="search" value="<?php echo $VM_LANG->_('PHPSHOP_SEARCH_TITLE') ?>"> </div></td> </tr> </table> <?php } // end - There is a published Product Type /** Changed Product Type - End */ ?> </form> and this is what i made ( i need to say that i'm note the coder i just try to change it myself) to make <input> chceckbox <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); /** * Paramater search for phpShop * @author Zdenek Dvorak (zdenek.dvorak@seznam.cz) * * @version $Id: shop.parameter_search_form.php 1452 2008-07-08 17:21:42Z soeren_nb $ * @package VirtueMart * @subpackage html * @copyright Copyright (C) 2004-2008 soeren - All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ $q = "SELECT * FROM #__{vm}_product_type "; $q .= "WHERE product_type_id='$product_type_id' "; $q .= "AND product_type_publish='Y'"; $db->query($q); $browsepage = $db->f("product_type_browsepage"); $vm_mainframe->setPageTitle( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $pathway[] = $vm_mainframe->vmPathwayItem( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $vm_mainframe->vmAppendPathway($pathway); echo "<h2>".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH')."</h2>"; if (!$db->next_record()) { // There is no published Product Type echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_BAD_PRODUCT_TYPE'); } else { echo "<table width=\"100%\" border=\"0\">\n<tr><td width=\"40%\">"; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IN_CATEGORY').": ".$db->f("product_type_name"); // Reset form echo "</td><td align=\"center\">"; echo "<form action=\"".$sess->url( $mm_action_url.basename($_SERVER['PHP_SELF']). "?page=shop.parameter_search_form&product_type_id=". $product_type_id ). "\" method=\"get\" name=\"reset\">\n"; echo "<input type=\"submit\" class=\"button\" name=\"reset\" value=\""; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_RESET_FORM') ."\">\n</form>"; echo "</td><td width=\"40%\"> </td></tr></table>\n"; ?> <form action="<?php echo URL ?>index.php" method="get" name="attr_search"> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="page" value="shop.browse" /> <input type="hidden" name="product_type_id" value="<?php echo $product_type_id ?>" /> <input type="hidden" name="Itemid" value="<?php echo $sess->getShopItemid() ?>" /> <br /> <?php $q = "SELECT * FROM #__{vm}_product_type_parameter "; $q .= "WHERE product_type_id=$product_type_id "; $q .= "ORDER BY parameter_list_order"; $db->query($q); echo "dupa1\n"; ?> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <?php /******************************************************** ** BrowsePage - You can use your tepmlate for searching: ** 1) write file with html table (without tags <table> and </table>) and ** take its name into variable browsepage in Product Type ** 2) You can use this page from tag <!-- Default list of parameters - BEGIN --> to ** tag <!-- Default list of parameters - END --> and changed it. ** 3) tag {product_type_<product_type_id>_<parameter_name>} will be replaced input field, or select field ** tag {product_type_<product_type_id>_<parameter_name>_comp} will be replaced comparison ** for this parameter. It is important for correct SQL question. ** tag {product_type_<product_type_id>_<parameter_name>_value} will be replaced value for this ** parameter (when you click on button "Change Parametes" in Browse page). ********************************************************/ if (!empty($browsepage)) { // show browsepage /** * Read the template file into a String variable. * * function read_file( $file, $defaultfile='') ***/ $template = read_file( PAGEPATH."templates/".$browsepage.".php"); echo "dupa2\n"; //$template = str_replace( "{product_type_id}", $product_type_id, $template ); // If you need this, use it... while ($db->next_record()) { $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $parameter_values=$db->f("parameter_values"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); $parameter_type = $db->f("parameter_type"); // Replace parameter value $template = str_replace( "{".$item_name."_value}", $get_item_value, $template ); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET $comp = "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; $comp .= "<form action=\"".$item_name."_comp\">\n"; $comp .= "<input type=\"checkbox\" value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."\n"; $comp .= "<input type=\"checkbox\" value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."\n"; $comp .= "</td>"; } else { // type: all other // Multiple section List of values - no comparison $comp = "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $comp = "<form action=\"".$item_name."_comp\" method=\"post\">\n"; $comp .= "<input type=\"checkbox\" value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"le\"".(($get_item_value_comp=="le")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"").">\n"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<form action=\"".$item_name."_comp\">\n"; $comp .= "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."\n"; $comp .= "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."\n"; $comp .= "<input type=\"checkbox\" value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."\n"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<form actio=\"".$item_name."_comp\">\n"; $comp .= "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."\n"; $comp .= "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."\n"; $comp .= "</td>"; } } // Relace parameter comparison $template = str_replace( "{".$item_name."_comp}", $comp, $template ); // Parameter field if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); $attr = "<select class=\"inputbox\" name=\"$item_name"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); $attr .= "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."</option>\n"; } } else { $attr .= "\">\n"; $attr .= "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n"; foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."</option>\n"; } } $attr .= "</select>"; } else { // Input field switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text $attr = "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } // Relace parameter $template = str_replace( "{".$item_name."}", $attr, $template ); } echo $template; } else { // show default list of parameters echo "\ndupa3\n<!-- Default list of parameters - BEGIN -->\n"; while ($db->next_record()) { $parameter_type = $db->f("parameter_type"); if ($parameter_type!="B") { echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $db->f("parameter_label"); if ($db->f("parameter_description")) { echo " "; echo mm_ToolTip($db->f("parameter_description"),$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION')); } echo " :</strong></div>\n </td>\n"; $parameter_values=$db->f("parameter_values"); $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; echo "<input type=\"checkbox\" value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."\n"; echo "<input type=\"checkbox\" value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."\n"; echo "</form></td>"; } else { // type: all other // Multiple section List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" >\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n</td>\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; echo "<input type=\"checkbox\" value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"")."><\n"; echo "<input type=\"checkbox\" value=\"le\"".(($get_item_value_comp=="le")?" selected":"")."><=\n"; echo "<input type=\"checkbox\" value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=\n"; echo "<input type=\"checkbox\" value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">>=\n"; echo "<input type=\"checkbox\" value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">>\n"; echo "<input type=\"checkbox\" value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"")."><>\n"; echo "</form></td>"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; //echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; echo "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; echo "<input type=\"checkbox\" value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n"; echo "</form></td>"; break; case "V": // Multiple Value echo "<td><input type=\"hidden\" value=\"find_in_set\" >\n</td>\n"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; echo "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."\n"; echo "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."\n"; echo "</select></td>"; } } if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); echo "<td width=\"55%\" height=\"2\" valign=\"top\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\" name=\"$item_name\"; >\n"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); //echo "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { echo "<input type=\"checkbox\" value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."\n"; } } else { echo "\">\n"; echo "<input type=\"checkbox\" value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."\n"; foreach($fields as $field) { echo "<input type=\"checkbox\" value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."\n"; } } echo "</select>"; } else { // Input field echo "<td width=\"55%\" height=\"2\">\n"; switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<input type=\"checkbox\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text echo "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char echo "<input type=\"checkbox\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } echo " ".$db->f("parameter_unit"); switch( $parameter_type ) { case "D": // Date & Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT')." "; echo $VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; case "A": // Date echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT').")"; break; case "M": // Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; } } else { // Break line (type == "B") echo "<tr>\n <td colspan=\"3\" height=\"2\" ><hr>"; } echo " </td>\n</tr>"; } echo "\n<!-- Default list of parameters - END -->\n\n"; } // Add search according to price: $item_name = "price"; $get_item_value = vmGet($_REQUEST, $item_name, ""); $item_name = "price_from"; $get_item_value_from = vmGet($_REQUEST, $item_name, ""); $item_name = "price_to"; $get_item_value_to = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $VM_LANG->_('PHPSHOP_CART_PRICE')." :</strong></div>\n </td>\n"; // input text echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_from\" value=\"$get_item_value_from\" size=\"20\" />"; echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_to\" value=\"$get_item_value_to\" size=\"20\" /></td>\n</tr>"; // Search Button ?> <tr><td colspan="3" height="2" > </td></tr> <tr><td colspan="3" height="2" ><div align="center"> <input type="submit" class="button" name="search" value="<?php echo $VM_LANG->_('PHPSHOP_SEARCH_TITLE') ?>"> </div></td> </tr> </table> <?php } // end - There is a published Product Type /** Changed Product Type - End */ ?> </form> Is ther anybody can help me with This. I will be very thankful for any Help. Similar TutorialsHi, I'm having a problem with a hidden input value not changing on the browser after a request. I can change the value and alert or console log the new value but it won't change the DOM. Here's the section I'm having problems with:
xhr.onload = function() { if (xhr.status === 200) { var data = JSON.parse(this.responseText); $(".token").attr('value', data.token); alert($(".token").val()); } else { console.log('Something went terribly wrong...'); } }; Edited by Millertime1, 16 August 2014 - 03:34 PM. I have a calendar select date function for my form that returns the date in the calendar format for USA: 02/16/2012. I need to have this appear as is for the form and in the db for the 'record_date' column, but I need to format this date in mysql DATE format (2012-02-16) and submit it at the same time with another column name 'new_date' in the database in a hidden input field. Is there a way to do this possibly with a temporary table or something? Any ideas would be welcome. Doug Can be those <input ...> types with values changed from a script ?. Imagine it like we have an admin and we want to change some input values with a generated form on that page instead of going source and changing 1 by 1 ? Hey guys. Me again... Essentially what i am doing is pulling data from a MySQL database about the number of thumbnails on a page. The user can then change this using a <select> dropdown menu. How ever, i want the <select> to default to the amount already specified by the Database. I know i can do this by inserting a Selected attribute to one of the <options> but what is the best way of doing this? Heres my code.. $NumberOfThumbnails = mysql_result($data, 0,"NumberOfThumbnails"); <select name="numberofthumbnails"> <option value="0">None</option> <option value="2">2</option> <option value="4">4</option> <option value="6">6</option> <option value="8">8</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="16">16</option> <option value="18">18</option> <option value="20">20</option> <option value="22">22</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> </select> Thanks - Danny hi i am in situation to display input box along with select option , here is my code <?php $run= $dbc->db("SELECT * FROM `table` WHERE `id`='$id'"); ?> <select name="service"> <?php while ($result = mysql_fetch_array($run)) { ?> <option value="<?php echo $result['id'] ; ?>"><?php echo $result['service'] ; ?></option> <?php // This is problem i need to get this as hidden field but it breaks my select options. ?> <input type="hidden" value="<?php echo $result['data'] ; ?>" name="data" /> <?php } ?> </select> so here i am stuck <input type="hidden" value="<?php echo $result['id'] ; ?>" name="data" /> when i repeat in while loop it breaks options box and display other options without in select box. any help please thanks Here's a question for all you great php programmers. What I want to do is use a variable username as the name of a select input of a form. I.E echo"<select name='$user'>"; Of course this code doesn't work though I feel sure that there must be a way to do this. Anyone know it? Hey guys! I'm making a locally run web based application for entering/storing/editing data. I am trying to do this thing where I export a 'records.txt' file to a different location which can be selected by the user. I have a lame <input type='text' value='H:\'> box going on which I was going to use to define the path for the file to be saved, but I want to be able to use a pop up windows (or whatever native OS finder application) just like the one which appears when you use <input type='file'>. Now that I think about it, I think this is more of a html question, but it's 2.30am and my project is due today... See! what the hell, I just habitually pressed ctrl-s after working in dreamweaver for hours and the exact function which I am looking for popped up, how do I do that?! Please thanks guys I have a search function in php where the text characters are matched to characters in a tables field--- works perfectly.... I need to make the input box have a droplist of words from database, this is also easy for me to do. the problem here is there is no definitive value! the options list always outputs a blank in the url--- its supposed to search a matching value and then output the matching value to url... Here is the droplist code: $output['RATESTITLE']='<input class="inputbox" type="text" size="24px" name="ratestitle" value="'.$sch->filter['ratestitle'].'" onfocus="if (this.value ==\''.$output['LANGUAGE_SEARCH_RATESTITLE'].'\') {this.value = \'\'}" />'; this outputs a input text box--- i want to have a droplist of options to populate this text box... If you must know this is the third day im at it... I've a simple Inset List (jQuery Mobile) of several items with a Flip switch, Drop down, check box and Slider elements. I have wrapped this Inset List inside a HTML Form. <code> <div data-role="fieldcontain"> <ul data-role="listview" data-inset="true"> <li data-role="list-divider"> Inhouse capabilities </li> <li> <label for="flip-b">Project Manager</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li> <label for="flip-b">Site Supervisor</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li><label for="flip-b">Architect</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li><label for="flip-b">Builderworks</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li><label for="flip-b">Electrical</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li><label for="flip-b">Mechanical</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li><label for="flip-b">Hydraulics</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li><label for="flip-b">Joinery</label> <select name="slider" id="flip-b" data-role="slider"> <option value="no">No</option> <option value="yes">Yes</option> </select> </li> <li> <label for="select-choice-1" class="select">Main Location:</label> <select name="select-choice-1" id="select-choice-1"> <option value="NSW">NSW</option> <option value="ACT">ACT</option> <option value="VIC">VIC</option> <option value="SA">SA</option> <option value="QLD">QLD</option> <option value="NT">NT</option> <option value="WA">WA</option> <option value="TAS">TAS</option> </select> </li> <!-- Select Menus: Main Location--> <li> <div data-role="fieldcontain"> <fieldset data-role="controlgroup"> <legend>CBA Reference</legend> <input type="checkbox" name="checkbox-1a" id="checkbox-1a" class="custom" /> <label for="checkbox-1a">Commercial</label> <input type="checkbox" name="checkbox-2a" id="checkbox-2a" class="custom" /> <label for="checkbox-2a">Retail</label> </fieldset> </div> </li> </ul> </div> <!-- End of Field Contain div tag --> <a href="#additionalinfo" data-role="button" data-inline="true" data-iconpos="left" data-theme="b">Additional Info</a> <a href="./search2.html" rel="external" data-ajax="false" data-role="button" data-inline="true" data-icon="search" data-iconpos="left" data-theme="e">Search</a> </code> I want to know, how I can include only the elements the user selected in my SQL query. Lets say, User wants to find the Electrical workers in QLD, then he will select Yes for Electrical and QLD as Main Location and the other items he would not touch. Now, how can I include only those two values in the select clause. Say, Select Electrical, Main Location from table where Main location='QLD'. I used POST method to gather users input. I use PHP, MySQL for this project. Any ideas on how to achieve this. Regards Sandeep Hey guys,
Thank you in advance... here is my situation, I have a form with three (3) fields in it, the 'student name' is unlimited textfield with an "add more" button to it and I have two select fields ('number of shirts' and 'trophies') that depend on the number of entries for 'student name'...
I want to create the select fields based on this math, for as many 'student name' entries:
1- i want to have the select form for 'number of shirts' to be 0 up to that number... so if there are 6 'student name' entries, the select options will be 0,1,3,4,5,6,7
2- I want to have the select form for 'trophies' to be 5 'student name' entries to 1 'trophies', for example if there are 6 'student name' entries, the select options will be 0,1... if there are 13 entries, options will be 0,1,2... So if there are less than 5 'student name' entries, the select field will not show (hidden)
of course if there are no 'student name' entries, these two fields won't show up (hidden)
let me know if that make sense and ANY help or directions will be GREATLY APPRECIATED.
Thanks guys!
hirealimo.com.au/code1.php this works as i want it: Quote SELECT * FROM price INNER JOIN vehicle USING (vehicleID) WHERE vehicle.passengers >= 1 AND price.townID = 1 AND price.eventID = 1 but apparelty selecting * is not a good thing???? but if I do this: Quote SELECT priceID, price FROM price INNER JOIN vehicle....etc it works but i lose the info from the vehicle table. but how do i make this work: Quote SELECT priceID, price, type, description, passengers FROM price INNER JOIN vehicle....etc so that i am specifiying which colums from which tables to query?? thanks I hope I can explain what is happening. I have created two forms in PHP. The first 'almost' works, i.e. it shows the data. But I have two problems - 1) the second pulldown menu is always empty and 2) $value from the first pulldown menu ALWAYS equals the last entry thus the last 'if' in the function subdomains ($domains) is always called (but still empty). The code may explain this better than me:
<!DOCTYPE html> <html> <body> <!-- processDomains.php is this file - it calls itself (for testing purposes so I can see what is happening) --> <form action="processDomains.php" method="post"> <?php // create the domains array (there are actually several entries in the array but I cut it down for testing) $domains = array (1 => 'Decommission', 'Migration'); echo "Select Domain:"; echo "<br>"; // Make the domain pull-down menu - this displays correctly echo '<select name="domain">'; foreach ($domains as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; // input doesn't matter what is 'submitted', always goes to last $value echo '<input type="submit" name="submit" value="Submit">'; // call function subdomains subdomains ($value); function subdomains ($domains) { // define values for each array - each array contains available choices for the subdomain pulldown menu $migration = array (1 => 'Application Migration', 'Application Patch', 'Application Upgrade'); $decommission = array (1 => 'Applications', 'Servers', 'Storage'); if ($domains === 'Migration') { echo "Select subdomain:"; echo "<br>"; // Make the Migration pull-down menu echo '<select name="migration">'; foreach ($migration as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; } else if ($domains === 'Decommission') { /* === * since 'Decommission' is the last entry in the 'Domains' pulldown list, $value ALWAYS equals * 'Decommission' and $domains equals $value. So this menu SHOULD work but is always * empty. Thus, two problems - the pulldown menu is always empty and $value isn't based * upon user input. */ echo "Select subdomain:"; // this prints so I know I'm in 'Decommission (I eliminated the echo "$domain" to show I'm always coming here)' echo "<br>"; // Make the 'Decommission' pull-down menu echo '<select name="decommission">'; foreach ($decommission as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; echo '<input type="submit" name="submit" value="Submit">' ) // end of 'if-else' } // end of function 'subdomain' ?> </form> </body> </html>Let me say thank you in advance and I appreciate the help! I know I'm doing something (or more than one thing) wrong and I hope someone can tell me what it is. Best Regards! Edited by mac_gyver, 19 January 2015 - 09:37 PM. code tags around posted code please I am writing a script that will parse my PHP classes and check for things like coupling, visualize my objects and connections, dependencies, check for convention usage, etc.
So, I have a simple file upload. I'm never saving the files, just get contents and dump the file and work with the string version.
I'm writing it for me, but I figure I might want to open it for others to use in the future, so I may as well write it that way to begin with -- so I need to validate user input. Problem is, the user input is supposed to be valid PHP code. I'm thinking that, as long as I'm careful, I shouldn't be executing any code contained in strings, but I'm no security expert and I want a warm fuzzy that my thought on this is correct. What kinds of things do I need to look out for? Is it possible to inject when working with strings?
My initial thought is to regex the entire file and replace key portions with known replacements. So ( and ) would become !* and !^ or $ would become @~ (combinations that -- I think -- don't make sense to php?) But that may be completely unnecessary processing time if I'm not in any danger, here. Thanks ahead of time for any help.
PS - as a side question -- what's the best way to verify a file is a php file? I know of getimagesize for images, but should I just check for <? to verify it's php? That seems like it would be too easy to fool -- then again, it might not matter much.
-Adam
I have 2 queries that I want to join together to make one row
Dear All, I wish to have 2 drop down boxes, Country Select Box and Locality Select Box. The locality select box will be affected by the value chosen in the country select box. All is working fine except that the locality select box is not being populated. I know that the problem is in the sql statement WHERE country_id='$co' because i am having an error that $co is an undefined variable. All the rest works fine because i have replaced the $co variable directly with a number (say 98) for a particular country id and it worked fine. In what way can i define this variable $co so that it is accepted by my sql statement? Thank you for your help in advance. MySQL Tables indicated below: CREATE TABLE countries( country_id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT, country_name VARCHAR(30) NOT NULL, PRIMARY KEY(country_id), UNIQUE KEY(country_name), INDEX(country_id), INDEX(country_name)) ENGINE=MyISAM; CREATE TABLE localities( locality_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, country_id INT(3) UNSIGNED NOT NULL, locality_name VARCHAR(50), PRIMARY KEY (locality_id), INDEX (country_id), INDEX (locality_name)) ENGINE=MyISAM; Extract PHP script included below: // connect to database require_once(MYSQL); if(isset($_POST['submitted'])) { // trim the incoming data /* this line runs every element in $_POST through the trim() function, and assigns the returned result to the new $trimmed array */ $trimmed=array_map('trim',$_POST); // clean the data $co=mysqli_real_escape_string($dbc,$trimmed['country']); $lc=mysqli_real_escape_string($dbc,$trimmed['locality']); } ?> <form action="form.php" method="post"> <p>Country <select name="country"> <option>Select Country</option> <?php $q="SELECT country_id, country_name FROM countries"; $r=mysqli_query($dbc,$q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); while($row=mysqli_fetch_array($r)) { $country_id=$row[0]; $country_name=$row[1]; echo '<option value="' . $country_id . '"'; if(isset($trimmed['country']) && ($trimmed['country']==$country_id)) echo 'selected="selected"'; echo '>' . $country_name . '</option>\n'; } ?> </select> </p> <p>Locality <select name="locality"> <option>Select Locality</option> <?php $ql="SELECT locality_id, country_id, locality_name FROM localities WHERE country_id='$co' ORDER BY locality_name"; $rl=mysqli_query($dbc,$ql) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); while($row=mysqli_fetch_array($rl)) { $locality_id=$row[0]; $country_id=$row[1]; $locality_name=$row[2]; echo '<option value="' . $locality_id . '"'; if(isset($trimmed['locality']) && ($trimmed['locality']==$locality_id)) echo 'selected="selected"'; echo '>' . $locality_name . '</option>\n'; } // close database connection mysqli_close($dbc); ?> </select> </p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> Hi people, I really hope you guys can help me out today. I'm just a newbe at php and i'm having real trouble. Bassically all I want to do is have a user type in a company name in a html form. If what the user types in the form matches the company name in my php script i want the user to be sent to another page on my site. If what the user types in the form doesnt match the company name in my php script i want the user to be sent to a differnt page like an error page for example. this is my html form: Code: [Select] <form id="form1" name="form1" method="post" action="form_test.php"> <p>company name: <input type="text" name="company_name" id="company_name" /> </p> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> And this is the php code I'm trying to process the information on: Code: [Select] <?php $comp_name = abc; if(isset ($_POST["company_name"])){ if($_POST["company_name"] == $comp_name){ header("Location: http://www.hotmail.com"); exit(); } else{ header("Location: http://www.yahoo.com"); exit(); } } ?> The thing is i'm getting this error when i test it: Warning: Cannot modify header information - headers already sent by (output started at D:\Sites\killerphp.com\form_test.php:10) in D:\Sites\killerphp.com\form_test.php on line 17 Please can some one help me out, i'm sure this is just basic stuff but i just cant get it to work Cheers. As I am VERY new to PDO, can someone help me in converting the below 2 codes so that I can setup the testing site knowing at least this part works. Below is the old SQL that I need to convert but don't have to foggiest on where to start. If I can get some help with this I can slowly work through the rest of my site with a bit more ease. LOGIN CODE: <?php if($_POST['submit']){ $Username = protect($_POST['Username']); $Password = protect(sha1($_POST['Password'])); if(!$Username || !$Password){ echo "<center>Please enter your <b>Username</b> and <b>Password</b>!</center>"; }else{ $res = mysql_query("SELECT * FROM `eusers` WHERE `Username` = '".$Username."'"); $num = mysql_num_rows($res); if($num == 0){ echo "<center>The <b>Username</b> or <b>Password</b> you supplied is incorrect!</center>"; }else{ $res = mysql_query("SELECT * FROM `eusers` WHERE `Username` = '".$Username."' AND Password = '".$Password."'"); $num = mysql_num_rows($res); if($num == 0){ echo "<center>The <b>Password</b> you supplied is incorrect!</center>"; }else{ $row = mysql_fetch_assoc($res); if($row['Active'] != 1){ echo "<center>Your login has been <b>deactivated</b>, Please contact your Manager for assistance.</center>"; }else{ header('Location: secure.php'); $time = date('U')+7200; //2 Hours mysql_query("UPDATE `eusers` SET `Online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); $_SESSION['uid'] = $row['id']; }}}}} ?> ACCESS GRANTED (Each Page): <?php if(strcmp($_SESSION['uid'],"") == 0){ printf("<script>location.href='index.php'</script>"); }else{ $time = date('U')+7200; //2 Hours $update = mysql_query("UPDATE `eusers` SET `Online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); } ?>
Hi, I am changing my ISP and need to import my databases.
Do I I have to create a new datarbase or can I change my database name to import?
My new host has a different database prefix ie: -web147xxxxxxxx
My old one was arewene1_wor1.
Many thanks.
Salting passwords... How can you update the salting without getting all the users to change their password? Is the salting set in stone once created? okay i need help with this part of code i need to set time 00:00 to 24:00 Code: [Select] $vrijeme_otvoreno = "$rv_od_h:$rv_od_min"; $vrijeme_zatvoreno = "$rv_do_h:$rv_do_min"; if ($vrijeme_otvoreno =="00:00" && $vrijeme_zatvoreno == "00:00") { $vrijme_zatvoreno = "24:00"; echo $vrijeme_zatvoreno; } echo "$vrijeme_otvoreno - $vrijeme_zatvoreno <br>"; i get echo 00:00 - 00:00 and i need it to be 00:00 - 24:00 |