PHP - Using Php Variable In Html Select Input Forms Name
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? Similar TutorialsI've been poking around online for about a day now trying to find a good way to do the following: I have an "order" I'm reading in from a MySQL database (not completely relevant, but just fyi). And, for this order there are a number of "parts" (automotive parts) that have been ordered. For each part there is data pertaining to the quantity of parts that have been ordered and the number of parts that have been allocated (based on our inventory) and then a third column that has the number of parts still in that order that are still to be allocated at a future date. Basically, I'm displaying this data in a form with each row having a checkbox to the far left. What I want to do is allow the user to check any number of check boxes. If a check box is checked the form should submit all of the input text boxes for that row (the user can update the quantities) that I talked about in the second paragraph for that "part" (each part is displayed in a row and has a checkbox). Unfortunately, most of the examples I found for checkboxes in a form submit a specific value (like a number of a letter). I need the form to submit the values that are in the textboxes. So basically, I'm thinking I need the page to update a PHP object whenever the value of a textbox is changed and then when the user clicks a button it will send the php object for each checked row through GET or POST. But, how would I get it to onchange update a PHP object (the PHP object would need to be a 2-D array where the first index allows you to select the part and the second index allows you to select which quantity you will change). I'm thinking I would need to call a script from the onchange like: onchange="somePHPfunction(partNumberIndex, whichQuantityI'mChanging, currentValueOfThatQuantity)" but of course that would require me to embed some php inside the onchange call since the partNumberIndex and whichQuantity are PHP variables.. Any ideas on how to do this sort of thing? Or any ideas on how to do this differently? I'm trying to avoid javascript because it would place a javascript constraint on the users. But, maybe there's no other way to do this sort of thing? Any help would be greatly appreciated! Hi, I have made a basic html site and it has two forms on it. I have the forms linking to a file called process.php. Basically i need to know what code to put in the php file in order for the forms to save whatever is entered in them to a txt file on my server or computer. Or any other easier way to do the same thing, save the content of two forms on my site. Hope i posted this in the right forum subject. Thanks very much for anyone that helps. 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 Hello all. I am very new to PHP, and I am not sure where to look or what I'm looking for in my current assignment. My task is to take in two numbers between 0-100. Once I take in that number, it should state beside it "The __ was accepted." The program should not accept any numbers greater than 100 or any characters. Once I do this, I must take a second number and do a similar thing. Finally, I must have a statement show up at the bottom stating which number is greater. Essentially, I need help in determining what I should use to place parameters, and how I can keep the program from echo ing any statement until input has been taken and tested for parameters. Any help you can provide will be greatly appreciated! 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 Guys, quick one. Im writing a script for a form to post info into a MySql table. Now rather than just having a single row for input I'd like to have lets say 10 rows, so I can add 10 records to the database. What I'm pondering is 2 things: 1: can i just repeat Code: [Select] <input type="text" name="opponent" size="27" /> over and over, or is it going to need its own name each time for example; Code: [Select] <input type="text" name="opponent2" size="27" /> <input type="text" name="opponent3" size="27" /> 2: when it comes to the processing script is it more economical to have the forms input field named the same over and over (if it IS possible) and if not whats the most econimcal way to code my Code: [Select] $opp= $_POST['opponent']; $query="INSERT INTO fixtures (match_date, season, opponent) VALUES ('$date', '$season', '$opp',)"; Your help and comments are appreciated as always guys Tom Here is my code below. What I’m having a problem with is trouble to find how to sticky my checkbox and get to the confirmation page after clicking the submit input. I also need on the confirmation page to list what fields are not filled in.
<head> <meta http-equiv="Content-Type"content="text/html; charset=utf-8' /> <title>Assignment 4</title> <style type="text/css" title="text/css" media="all"> </style> </head> <div align="center"> <img src="nba2k20cover.jpg" alt="nba2k20 cover" width="616" height="353" /> <br> <br> <?php include('header.php'); ?> <h4> Hosted by: Zang Thao</h4> <h5> You are required to complete every field to your best!</h5> <body> <?php $name = $_POST['name']; $comments = $_POST['comments']; $gender = $_POST['gender']; $email = $_POST['email']; $league = $_POST['league']; $submit = $_POST['submit']; $monthsarray = array("Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $days = range(1,31); $daysdefault = array ('Day'); $daysarray = array_merge($daysdefault, $days); $years = range(2002,1910); $yearsdefault = array ('Year'); $yearsarray = array_merge($yearsdefault, $years); ?> <form name ="fbForm" id="fbForm" action="<?php if(($errors = NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')) { echo "handle.php"; $submit = true; } else { echo "index.php"; } ?>" method="post"> <fieldset><legend>Fill out the registration form below:</legend> <?php if(($_POST['name'] == NULL) && ($_SERVER['REQUEST_METHOD'] == 'POST')) { echo "<b>Please enter a name!</b>"; } ?> <p><label>Name: <input type="text" name="name" size="20" maxlength="40" value="<?php echo $_POST['name']; ?>" /></label></p> <?php if($_POST['email'] == NULL) { echo "<b>Please enter your email!</b>"; } ?> <p><label>Email Address: <input type="text" name="email" size="40" maxlength="60" value="<?php echo $_POST['email']; ?>" /></label></p> <?php if($_POST['gender'] == NULL) { echo "<b>Please select your gender!</b>"; } ?> <p><label for="gender">Gender:</label><input type="radio" name="gender" value="M"<?php if($_POST['gender'] == "M") { echo "checked"; } ?> /> Male<input type="radio" name="gender" value="F" /> Female</label></p> <?php if($_POST['month'] == NULL) { echo "<b>Please enter a birthday!</b>"; } ?> <p><label>Birth Date: <select name="month"> <?php foreach ($monthsarray as $value) { if($_POST['month'] == $value) { $isselected = "selected"; } else { $isselected = ""; } echo "<option value='$value' $isselected>$value</option> \n"; } ?> </select> <select name="day"> <?php foreach ($daysarray as $value) { if($_POST['day'] == $value) { $isselected = "selected"; } else { $isselected = ""; } echo "<option value='$value' $isselected>$value</option> \n"; } ?> </select> <select name="year"> <?php foreach ($yearsarray as $value) { if($_POST['year'] == $value) { $isselected = "selected"; } else { $isselected = ""; } echo "<option value='$value' $isselected>$value</option> \n"; } ?> </select></label></p> <?php if($_POST['league'] == NULL) { echo "<b>Please select a league!</b>"; } ?> <p><label for="league">Choose your league:</label><input type="checkbox" name="league" value="A"<?php if($_POST['opt'] == "A") { echo "checked"; } ?> /> A <input type="checkbox" name="league" value="B" <?php if($_POST['opt'] == "B") { echo "checked"; } ?>/> B <input type="checkbox" name="league" value="C" <?php if($_POST['opt'] == "C") { echo "checked"; } ?>/> C <input type="checkbox" name="league" value="D" <?php if($_POST['opt'] == "D") { echo "checked"; } ?>/> D</p> <?php if($_POST['comments'] == NULL) { echo "<b>Write down your questions/concerns if you don't have any write N/A!</b>"; } ?> <p><label>Questions/Concerns: <textarea name="comments" rows="3" cols="40"><?php echo $_POST['comments']; ?></textarea></label></p> </fieldset> <?php if ($submit) { echo"<script>document.getElementById('fbForm').submit();</script> "; } ?> <p align="center"><input type="submit" name="submit" value="REGISTER!" /></p> </form> <?php include('footer.php'); ?> </body> </html>
On all my forms, after I send an empty string to one field, it will stop accepting values when I resubmit. My code passes through the W3C validator Any ideas?? 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 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'd describe myself as a "basic" php programmer....
I'm trying to build my first multi-page forms.
The first page is calculator_q1.php
No session variables are needed here, I have omitted a few options, the code looks like this
<form id="page1" method="post" action="calculator_q2.php"> <h1>1. Which best describes the primary and secondary sports combination that will be played on your pitch?</h1> <table> <tr><td>Rugby only</td><td><input type="radio" name="1_primary_secondary_combo" value="Rugby only"></td></tr> <tr><td>Rugby/Soccer</td><td><input type="radio" name="1_primary_secondary_combo" value="Rugby Soccer"></td></tr> <tr><td>Soccer/Hockey</td><td><input type="radio" name="1_primary_secondary_combo" value="Soccer Hockey"></td></tr> </table> <input class="blue" type="submit" value="Next"> </form>The 2nd page is calculator_q2.php. This has some php to start the session, copy the result of form 1 to a session var, I do a debug echo and the variable is printed correctly so I think have captured it correctly. In extract, I do this: <?php //Start the session session_start(); //Store our posted values in the session variables $_SESSION['1_primary_secondary_combo'] = $_POST['1_primary_secondary_combo']; ?> <?php $debug=True; if ($debug) { echo ("Debug: session for q1 = ".$_SESSION['1_primary_secondary_combo']); } ?> <form id="page2" method="post" action="calculator_q3.php"> <h1>2. Please choose a preferred surface</h1> <table> <tr><td>3G Rubber Crumb Filled Turf</td><td><input type="radio" name="2_preferred_surface" value="3G Rubber Crumb Filled Turf "></td></tr> <tr><td>Sand Filled Turf</td><td><input type="radio" name="2_preferred_surface" value="Sand Filled Turf"></td></tr> <tr><td>Sand Dressed Turf or<br>a Water Based Surface</td><td><input type="radio" name="2_preferred_surface" value="Sand Dressed Turf or a Water Based Surface"></td></tr> </table> <p> <script> function submitForm(action){ document.getElementById('page2').action = action; document.getElementById('page2').submit(); } </script> <input class="blue" type="button" onclick="submitForm('/calculator_q1.php')" value="Previous" /> <input class="blue" type="button" onclick="submitForm('/calculator_q3.php')" value="Next" /> </form>So far so good, but when I introduce page 3 (calculator_q3.php) then it prints the previous page's (from page 2) variable but can't find the session variable from question 1. This is from calculator_q3.php: <?php //Start the session session_start(); //Store our posted values in the session variables $_SESSION['2_preferred_surface'] = $_POST['2_preferred_surface']; ?> <?php $debug=True; if ($debug) { echo ("Debug: session for q1 = ".$_SESSION['1_primary_secondary_combo']); echo ("<br>Debug: session for q2 = ".$_SESSION['2_preferred_surface']); } ?> <form id="page3" method="post" action="calculator_q4.php"> <h1>3. Please choose one watering option</h1> <table> <tr><td>With a Rain Gun System</td><td><input type="radio" name="3_watering_option" value="With a Rain Gun System"></td></tr> <tr><td>With a Rain gun System + Water Borehole</td><td><input type="radio" name="3_watering_option" value="With a Rain gun System + Water Borehole"></td></tr> <tr><td>Not Required</td><td><input type="radio" name="3_watering_option" value="Not Required"></td></tr> </table> <p> <script> function submitForm(action){ document.getElementById('page3').action = action; document.getElementById('page3').submit(); } </script> <input class="blue" type="button" onclick="submitForm('/calculator_q2.php')" value="Previous" /> <input class="blue" type="button" onclick="submitForm('/calculator_q4.php')" value="Next" /> </form>To see this in action see: http://www.sports.ha...lculator_q1.php Any insights would be appreciated. Many thanks. 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 Hi guys, the following code gives the parsing error "unexpected T_VARIABLE": Code: [Select] <?php $con = mysql_connect("localhost","XXX", "YYY"); if (!$con) {die('Could not connect: ' . mysql_error("oop"));} mysql_select_db("XXX_testDB") or die(mysql_error()); $counter = 1; $Tcounter = 1; $Tresult = mysql_query("SELECT * FROM NameTable WHERE id = $Tcounter"); $Trow = mysql_fetch_array($Tresult); $result = mysql_query("SELECT * FROM "$Trow['NameOfTable']" WHERE id = $counter"); $row = mysql_fetch_array($result); echo $row['TQuestion']; ?> So I have a Table in Mysql that is called 'NameTable'. From that table I am drawing an element in the 1st row under the column of NameOfTable. I want to call another element of another table through the table I described using a variable. Like this: Code: [Select] $result = mysql_query("SELECT * FROM "$Trow['NameOfTable']" WHERE id = $counter"); "$Trow['NameOfTable']": I also tried using single quotes or without and it doesn't work either. What is wrong with this? 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... Hi. I need some help getting my preg_match regex working with a variable input. I'm trying to limit visits to once per day, after you come the first time, you are added to data.txt and will be denied if you come again. The code works, but I need to limit the searches using ^ and $ and I'm having some difficulty. $number will be a number input from an html form ranging from 1-1000+ and I want to make sure that 1,10,100 etc., aren't treated as the same. here is my preg_match, how do I use regular expressions with $number? Code: [Select] preg_match("/$number/", $file, $match) from what I have read, it should be like this, but it doesn't work Code: [Select] preg_match('/^+$' , "/$number/", $file, $match) heres the full code Code: [Select] $filename = "data.txt"; $handle = fopen($filename, "r"); $file = fread($handle,filesize($filename)); if (preg_match("/$number/", $file, $match)) { echo " Sorry, Already visited today"; exit; } else { fclose($file); $file=fopen(data.txt,"a") or exit("Unable to open file!"); fwrite($file, "$number"); fwrite($file, "\n"); fclose($file); echo " Accepted!"; exit; } Thanks So basically I want to take this input "site:google.com" And record only the "google.com" part as a variable. Any idea how to do that? Well this may sound confusing. I tried to findways to allow users to input an integer value and then assign it to a variable called $quantity, but all I could find from the internet was the usage of forms. Do I have to use forms, or can I just try this this simple syntax: $quantity = "<input name='quantity' type='text' id='quantity' size='3' maxlength='3'>"; If I do have to use forms, then how can I ever assign user's input value to a variable? Please help. I am currently using a javascript to redirect the page using a select tag and the onchange property. Each page calls a different function. I want to be able to pass the <select> value to a variable that I can use within a php condition statement on the same page. This will generate the required output based on the <select> value. This way I dont require a seperate page for each query. So onchange.... $select_value == this.value? Then within my page: Code: [Select] if ($select_value == 'alpha') { get_query_alpha(); } if ($select_value == 'bravo') { get_query_bravo(); } This is my current set up... Code: [Select] <p>Order by: <select name="query" id="query" onchange="gotourl(this.value)"> <option value="query1.php" >Sort by A</option> <option value="query2.php" >Sort by B</option> <option value="query3.php" >Sort by C</option> <option value="query4.php" >Sort by D</option> </select></p> <table> <?php get_query_1();?> </table> and js... Code: [Select] function gotourl(url){ window.location= url; } function selectsubject(){ alert("Please select a subject!"); } Is there a simple way to do this? Thanks. What's the correct syntax for having a variable in a select statement? Here's an example of what I'm trying to do (after I'm already connected to the database). Code: [Select] $username = "thomas"; $query = mysql_query( "SELECT * from users WHERE username = $thomas" ); if( mysql_num_rows( $query ) > 0 ) { bla bla... It works if I don't put the WHERE part in, but I get an error if I use it, so I'm assuming I have the wrong syntax for using a variable in the select statement. 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 |