PHP - Changing Input Values ?
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 ?
Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, 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. Hi, I'm using the following code: <td>$row[color]</td> and the possible values for this field are 1, 2 and 3. But I want the return to be red for 1, blue for 2, and green for 3. How do I write it so that instead of getting a row of 1's, 2's and 3's, I change those numbers to their corresponding colors? Thanks! I have a form for a sign in page that I want the label for the form field to actually be displayed in the text box and clear when the box is selected to enter text. I've accomplished this using the code below and it works fine. The problem that I'm having is in IE the password field does not change to display dots or asterisk in place of each character. It works fine in Fire Fox but not in IE. Is there way to accomplish this using php or so that it is compatible with most browsers? Here's the code that I'm using: Code: [Select] <?php echo "<input type=\"text\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000'; this.type='password';}\"> "; ?> Hi Just learning PHP and I'm struggling with a very simple problem. I'm playing around with arrays as i figure they're one of the most important things to know inside out but I can't work out how to change the value of an array element via a loop. I can obviously do it if I just directly write $cars[2] = "test" but not having any luck with the loop. I've tried using "foreach" and passing a new value to the $value variable but when i do a print_r the values in the array are unchanged. Code: [Select] $cars[0]="Saab"; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota"; foreach ($cars as $key => $value) { $value = "TEST"; echo $key . " " . $value . "<br />"; } print_r($cars) I then tried using a for loop Code: [Select] for ($i=0; $i <= count($cars); $i++) { echo $cars[$i]; $cars[$i] = "2"; } But this code just threw up a fatal error as follows: "Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16 bytes) in /home/zzzzzzzz/public_html/php_testing/arrays.php on line 27" So would someone be kind enough to explain where i'm going wrong and why i get the fatal error on the second for loop. Thanks Drongo 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. I'm not completely sure how to implement this so I'd like to ask you to give me an idea if you can For a tennis booking system.. it will look something similar to (should be a table but this is for the sake of the idea) Date: Oct 25th, 2010 (go to oct 26) Court 1 Court 2 Court 3 Court 4 8:00 Open(bookit) Tally Open Hellio 9:00 Andy Roger Barney Training ...etc Now everyday, this table should be empty, so new bookings can be made how would I make it so a new table is empty /or has dif bookings every day (based on date) efficiently? Im guessing I will have dif values in the sql table for dif dates but what I'm not sure of is how to display it in page for ex, if someone presses the button oct 26, the new table is for that date, wif diff values Hi I have an array which looks like this when i do a print_r(): Array ( => Array ( [path] => 1 [order] => 2 ) [1] => Array ( [path] => 2 [order] => 1 ) [2] => Array ( [path] => 3 [order] => 2 ) ) In this instance, I want to change the values of the order key. So I do something like this so that the last array has a path of 3 and an order of 1, and the others have orders of 2 foreach ($old_images as $old_image){ if($old_image['path']==3){ $old_image['order']="1"; } else{ $old_image['order']="2"; } } When i step through, i see that the order is changed, but when i do a print_r(), i get the same result. So even though im resetting the order value of the inside arrays, the multidimensional array does not change.... any ideas? I am trying to make a Web Form for people to fill out that has two drop down menus where i want the first drop down menu's selection changes the values of the selections in the second drop down. ((IE. If the first drop down value is "product 01" then the second drop down shows values "Red, Green, Blue" while if the first drop down value is "product 02" then the second drop down shows values "Yellow, Green")) Anyone have any ideas? Thanks in Advance. Ok I am testing foreach in an array as my practice. I wonder how can I assign values in the key of the array.. Here's the code Code: [Select] <?php $username = me_mysql_prep(trim($_POST['username'])); $first_name = me_mysql_prep(trim($_POST['first_name'])); $last_name = me_mysql_prep($_POST['last_name']); $email = me_mysql_prep($_POST['email']); $position = me_mysql_prep($_POST['Position']); $password = me_mysql_prep($_POST['password']); $hashed_password = sha1($password); $required_fields = array($username,$first_name,$last_name, $email, $position, $password); foreach($required as $key => $value) { if($value == "") { echo $key . " Cannot be empty<br>"; } } ?> So the result would be like this... IF username, first name and last name are EMPTY it will echo: Quote username cannot be empty first name cannot be empty last name cannot be empty Anyone? I posted a topic earlier and there was confusion as to what I could not work out.
I am able to display the checkbox, either checked or unchecked depending of the value or 1 or 0 in the obcDisplay field.
<input type="checkbox" name="obcDisplay" value="<?=$r['obcDisplay'] ?>" <?=($r['obcDisplay']) ? 'checked="checked"' : ''; ?>/>I am trying to update the DB table by the checkbox. If the checkbox is checked (obcDisplay = 1) and I uncheck the box and submit, I want the table updated so that obcDisplay now equals 0. When the form is displayed, the checkbox is now uncheck (obcDisplay = 0). Now I check the box and submit and the update changes the field from 0 to 1. I can display the checkbox as checked or unchecked by the DB field obcDisplay being either 0 or 1. It is changing the value where I am having the problem. Short question: How can I get a string of HTML code and replace all the <input> tags with their values? Long question: I have a web page with a purchase order on it in HTML format and one or more of the columns is editable via input boxes. So the user can change the quantity/length of the material before submitting it. Once they choose to save it, it sends the string of HTML to a PDF generator (DOMPDF) which converts the HTML to a PDF file and saves it to the server. The user then has a hard copy of the purchase order PDF saved for each job. The problem is DOMPDF doesn't do well with <input> tags, it just leaves them as a blank space. So I want to take that string of HTML and replace all input boxes with their values before sending it to DOMPDF. Currently I'm using Javascript to do just that when the user clicks to save the modified purchase order. The problem with this is it only works for when the user modifies the purchase order and saves a new modified copy. I need to save a base unmodified copy of it when the page loads so this would strip all the input boxes from the page as soon as it loads and the user would no longer be able to edit anything. So I need something to send the string to DOMPDF when the page loads but not modify what's on the page. Any ideas? Thanks. I have the form: I have a textarea feild in my form where the user can type in several keywords such as Textarea Box Below Cars Trains Buses I have a database with the meanings of the words entered and want to be able to get the three definitions from the database on for submission. In a normal input box where i only type one word i can grab no problem like so $word = $_POST['word']; $sql = "SELECT meaning FROM table WHERE word='$word'"; Though i am trying to get multiple values from the same textarea box So if a user types in 3 words the query would query the database on thoses three words, the problem is i dont know how to get the diffrent words from the form for example $first = $_POST['word']; which would be the first word $sec = $_POST['word']; which would be the second word etc. Any help here would be great thanks. I am having trouble sending information that was entered into a form, on the same page to the next page. I am sure i have done this a few years ago but cant find the code and cant find the answer online, hope someone can help me. My code is as follows: <form method="POST" action="https://.............. .asp "> <table> <tr> <td>Name: </td> <td><input type="text" name="clientname" /></td> </tr> <tr> <td>E-mail:</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Contact No:</td> <td><input type="text" name="telno" /></td> </tr> </table> <?php $udate = date("y-m-d H:i:s", strtotime ("+2 hour")); $uniquevalue = "$udate" . " " . "Simpay Pro"; echo $uniquevalue; ?> <br /> <input type="hidden" name="info1" value="<?php print $uniquevalue?>"> <input type="hidden" name="info2" value=$clientname> <input type="submit" value="Submit"> </form> So basically info1 is working i can see the value on the next page after its submitted, but info2 is the value of the input field. Is this possible to do it like this, or do i have to send it to another page and then to my last page that displays the values? Hey Guys. I have a quick question. Should i "prep" input values coming from a radio or checkbox input field? Can an SQL injection occur through those 2 input fields, or is it only text fields?
Hi I have a form that is to input data from input fields to a table. The form is as follows: $query = $DB->query("SELECT country_code, country_id, IF(country_code = '".$country_code."', '', '') AS sel FROM exp_sme_countries WHERE site_id='".$this->settings['site_id']."' ORDER BY country_name ASC"); foreach ($query->result as $row) { $options .= '<label>' . 'Phrase for ' . $this->settings['countries'][$row['country_code']] . '</label>' . '<br />'; $options .= '<input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[]" />' . '<br /><br />'; $options .= '<input type="hidden" name="country_data[' . $row['country_id'] . ']" value="'.$row['country_id'].'" />'; } This outputs: Code: [Select] <input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[]" /> <input type="hidden" name="country_data[68]" value="68" /> <input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[]" /> <input type="hidden" name="country_data[28]" value="28" /> What I need to do, is get the values from the input fields and then match them with the correct hidden field value So if in the first input field, I typed in 'Test data' and the second input, i typed 'This is great' On the POST, I need to find the the value ('Test data') and also the value from the hidden field. So something like: Quote The text you entered is: Test data with hidden value of 68 The text you entered is: This is great with hidden value of 28 I'd rather not use $_GET as this is a form that inserts data into a database. Could someone point my in the right direction or provide an example? Well the topic may not sound very explicit. So I'll do my best to explain it here. I have a pull down menu as part of a form, which contains the months of the year. I'm trying to store the value of this form entry using the $_POST['month'] variable into a database but first, I need to convert the month values into their corresponding integer values( that is 1 for January, 2 for February etc), in order to easily do date calculations later down the road. Any ideas about how to do this? It may be helpful to include the code for the pull down menu. Code: [Select] <p><tab> Date of Birth: <?php //Make the month pull down menu. //Array to store months. $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); print '<select name= "month">'; foreach ($months as $key => $value) { print "\n<option value=\"$key\">$value</option>"; } print '</select>'; ?> </tab> <tab> <?php //Make the day pull down menu print '<select name= "day">'; for ($day = 1; $day <= 31; $day++) { print "\n<option value=\"$day\">$day</option>"; } print '</select>'; ?> </tab> <tab><?php //Make the year pull down menu print '<select name= "year">'; $start_year = date('Y'); for ($y = ($start_year - 18); $y >= 1900; $y--) { print "\n<option value=\"$y\">$y</option>"; } print '</select>'; ?> </tab> </p> Hi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Hi all, I'm a first time poster here and I would really appreciate some guidance with my latest php challenge! I've spent the entire day googling and reading and to be honest I think I'm really over my head and need the assistance of someone experienced to advise the best way to go! I have a multi dimensional array that looks like (see below); the array is created by CodeIgniter's database library (the rows returned from a select query) but I think this is a generic PHP question as opposed to having anything to do with CI because it related to working with arrays. I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence? Thanks in advance, as above, I've been searching really hard for the answer and believe i'm over my head! Output of print_r($updates); CI_DB_mysql_result Object ( [conn_id] => Resource id #30 [result_id] => Resource id #35 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 5 [row_data] => ) Output of print_r($updates->result_array()); Array ( [0] => Array ( [problem_update_id] => 1 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Some details about a paricular issue [problem_update_active] => 1 ) [1] => Array ( [problem_update_id] => 4 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Another update about the problem with an ID of 3 [problem_update_active] => 1 ) [2] => Array ( [problem_update_id] => 5 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of four [problem_update_active] => 1 ) [3] => Array ( [problem_update_id] => 6 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of 6 [problem_update_active] => 1 ) [4] => Array ( [problem_update_id] => 7 [problem_id] => 3 [problem_update_date] => 2010-10-12 [problem_update_text] => Some new update about the problem with the ID of 3 [problem_update_active] => 1 ) ) |