PHP - Value Of Option Menu Not Showing.
Something is wrong with this drop down form menu.
The name of the option appears and works well however the value does not seem to work. Any ideas? Thanks <?php include("cxn.php"); $query = "SELECT manufacturer FROM list ORDER BY manufacturer ASC"; $result = mysqli_query($cxn,$query) or die(mysqli_error()); ?> <select name="manufacturer" id="manufacturer"> <option value="" selected="selected">Select a Manufacturer..</option>"; <?php while($row = mysqli_fetch_row($result)){ echo "<option value=\"".$row[0]."\">".$row[0]."</option>"; // SHOWS ALL MANUFACTURERS CURRENTLY ADVERTISED WITH THE NUMBER OF ADVERTS NEXT TO THE MANUFACTURER } ?> Similar TutorialsI'm trying to create a dynamic option menu with one alert selected based on the first query to the db. Any help would be greatly appreciated. Code: [Select] //function to get alerts and create select menu with current alerts pre-selected function getALERTS1($id){ require('db.php'); $alert = mysqli_query($conn, "SELECT alert1 FROM visit_data WEHERE patientid = $id AND discharged IS NULL"); $row = mysqli_fetch_array($alert); $selects=null; $query = mysqli_query($conn, "SELECT alertid, name FROM alerts"); while($row1 = mysqli_fetch_array($query)) { $selects .= "<option value=\"" . $row1['alertid'] . "\"> if($row1['alertid']==$row['alert1']) { echo ' selected'; } ".$row1['name']."</option>"; } return $selects; } Hello to you all, Firstly, I have to admit - I know nothing about PHP coding. That said, I tried to make something work, kinda failed, partly done it, but it's not the way I need it. Let me explain. I'm working on some basic stuff on a woocommerce website. I changed the category tree of the products and now there are categories nested quite deep. Like - Parent category -> Subcategory -> Nested category -> Further nested category. That last piece wasn't showing on the sidebar, so I digged and found the PHP code responsible for showing categories. Upon finding the "Nested category" code, I simply copy-pasted it in a right place and then added CSS "display:block" rule. Now, the "Further nested category" is showing, when "Nested category" is active. But, here are the problems: 1. If there are multiple categories of that last depth for various "Nested categories", they are all showing; 2. When I click on a link of any "Further nested category", the page redirects correctly and shows all the required products, but the category tree is shrinking to "Parent categories" only. The store url is: https://skorpion.info.pl/sklep/. The problem #1 can be seen he https://skorpion.info.pl/kategoria/naczynia-i-przybory/naczynia-kuchenne-naczynia-i-przybory/ - as you can see, both "Garnki" and "Patelnie" nested categories show all of their consecutive further nested subcategories. The problem number two can be seen he https://skorpion.info.pl/kategoria/naczynia-i-przybory/naczynia-kuchenne-naczynia-i-przybory/patelnie-naczynia-kuchenne-naczynia-i-przybory/patelnie-aluminiowe/. The categories should remain visible. Let me post the code below, I'll mark with a comment the block I copy-pasted. I really hope someone can help me here, I would be massively thankful. Cheers! <aside class="sidebarWrapper"> <?php $types = array( 'hendi' => 'Hendi', 'stalgast' => 'Stalgast', 'bartscher' => 'Bartscher', 'kromet' => 'Kromet', 'hiendkitchen' => 'Hiendkitchen', ); ?> <ul class="parent-list"> <?php foreach ($types as $type => $value) : ?> <li> <a href="<?php echo home_url(); ?>/hurtownie/<?php echo $type; ?>"><?php echo $value; ?></a> </li> <?php endforeach; ?> </ul> <h2 class="title"> Kategorie <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 492.004 492.004" style="enable-background:new 0 0 492.004 492.004;" xml:space="preserve" width="512px" height="512px"> <g> <g> <g> <path d="M382.678,226.804L163.73,7.86C158.666,2.792,151.906,0,144.698,0s-13.968,2.792-19.032,7.86l-16.124,16.12 c-10.492,10.504-10.492,27.576,0,38.064L293.398,245.9l-184.06,184.06c-5.064,5.068-7.86,11.824-7.86,19.028 c0,7.212,2.796,13.968,7.86,19.04l16.124,16.116c5.068,5.068,11.824,7.86,19.032,7.86s13.968-2.792,19.032-7.86L382.678,265 c5.076-5.084,7.864-11.872,7.848-19.088C390.542,238.668,387.754,231.884,382.678,226.804z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#F1B63E" /> </g> </g> </g> </svg> </h2> <div class="slideDown-wrapper"> <?php $cate = get_queried_object(); $cateID = $cate->term_id; $cateParentID = $cate->parent; $mainCateParentObject = get_term($cateParentID); $mainCateParentID = $mainCateParentObject->parent; $args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => 0, 'orderby' => 'title', 'order' => 'asc' ); $product_cat = get_terms($args); foreach ($product_cat as $parent_product_cat) : ?> <ul class="parent-list"> <li class="<?php if ($parent_product_cat->term_id == $cateID || $parent_product_cat->term_id == $cateParentID || $parent_product_cat->term_id == $mainCateParentID) echo 'active'; ?>"> <a href="<?php echo get_term_link($parent_product_cat->term_id); ?>"> <?php echo $parent_product_cat->name; ?> </a> <?php if ($parent_product_cat->term_id == $cateID || $parent_product_cat->term_id == $cateParentID || $parent_product_cat->term_id == $mainCateParentID) : ?> <ul class="child-list"> <?php $child_args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $parent_product_cat->term_id ); $child_product_cats = get_terms($child_args); foreach ($child_product_cats as $child_product_cat) : ?> <li class="<?php if ($child_product_cat->term_id == $cateID || $child_product_cat->term_id == $cateParentID) echo 'active'; ?>"> <a href="<?php echo get_term_link($child_product_cat->term_id); ?>"> <?php if ($child_product_cat->term_id == $cateID) echo '<strong>'; ?> <?php echo $child_product_cat->name; ?> <?php if ($child_product_cat->term_id == $cateID) echo '</strong>'; ?> </a> <ul class="child-list"> <?php $child_args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $child_product_cat->term_id ); $child_product_cats = get_terms($child_args); foreach ($child_product_cats as $child_product_cat) : ?> <li> <a href="<?php echo get_term_link($child_product_cat->term_id); ?>"> <?php if ($child_product_cat->term_id == $cateID) echo '<strong>'; ?> <?php echo $child_product_cat->name; ?> <?php if ($child_product_cat->term_id == $cateID) echo '</strong>'; ?> </a> <!-- COPY-PASTED CODE FROM ABOVE--> <!-- --> <!-- --> <ul class="child-list" id="child-4-nest"> <?php $child_args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => $child_product_cat->term_id ); $child_product_cats = get_terms($child_args); foreach ($child_product_cats as $child_product_cat) : ?> <li> <a href="<?php echo get_term_link($child_product_cat->term_id); ?>"> <?php if ($child_product_cat->term_id == $cateID) echo '<strong>'; ?> <?php echo $child_product_cat->name; ?> <?php if ($child_product_cat->term_id == $cateID) echo '</strong>'; ?> </a> </li> <?php endforeach; ?> </ul> <!-- END OF COPY-PASTED CODE--> <!-- --> <!-- --> </li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> </ul> <?php endforeach; ?> </div> </aside> <aside class="saleProductsWrapper container p-0"> <h2 class="title">Promocje</h2> <div class="row"> <?php $cate = get_queried_object(); $cateID = $cate->term_id; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $loop = new WP_Query(array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => '1', 'meta_query' => array( array( 'key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ) ), 'orderby' => 'rand' )); while ($loop->have_posts()) : $loop->the_post(); ?> <div class="col-lg-12"> <?php get_template_part('template-parts/product'); ?> </div> <?php endwhile; wp_reset_query(); ?> </div> </aside>
Hello: I have a SELECT dropdown menu that works like this: Code: [Select] <?php $states_arr = array('AL'=>"Alabama",'AK'=>"Alaska",'AZ'=>"Arizona",'AR'=>"Arkansas",'CA'=>"California",'CO'=>"Colorado",'CT'=>"Connecticut",'DE'=>"Delaware",'DC'=>"District Of Columbia",'FL'=>"Florida",'GA'=>"Georgia",'HI'=>"Hawaii",'ID'=>"Idaho",'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas",'KY'=>"Kentucky",'LA'=>"Louisiana",'ME'=>"Maine",'MD'=>"Maryland", 'MA'=>"Massachusetts",'MI'=>"Michigan",'MN'=>"Minnesota",'MS'=>"Mississippi",'MO'=>"Missouri",'MT'=>"Montana",'NE'=>"Nebraska",'NV'=>"Nevada",'NH'=>"New Hampshire",'NJ'=>"New Jersey",'NM'=>"New Mexico",'NY'=>"New York",'NC'=>"North Carolina",'ND'=>"North Dakota",'OH'=>"Ohio",'OK'=>"Oklahoma", 'OR'=>"Oregon",'PA'=>"Pennsylvania",'RI'=>"Rhode Island",'SC'=>"South Carolina",'SD'=>"South Dakota",'TN'=>"Tennessee",'TX'=>"Texas",'UT'=>"Utah",'VT'=>"Vermont",'VA'=>"Virginia",'WA'=>"Washington",'WV'=>"West Virginia",'WI'=>"Wisconsin",'WY'=>"Wyoming"); function showOptionsDrop($array){ $string = ''; foreach($array as $k => $v){ $string .= '<option value="'.$k.'"'.$s.'>'.$v.'</option>'."\n"; } return $string; } ?> <form> <select name="states"> <option value="0">Choose a state</option> <?php echo showOptionsDrop($states_arr); ?> </select> </form> I would like to show all the towns/zipcodes for each individual state with an "onchange" from the SELECT menu. The table is called "zip_codes" and the City/Zip Codes are called "city" and "zip" What I would like to do is display them as links, so a user can click into each town and either create a new entry (a restaurant) or update an existing entry. What would be the best approach for this? I appreciate the help. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php //MySQL Database Connect include 'sqlconnect.php'; ?> <select name="aktivitet" id="aktivitet"> <?php //MySQL Database Connect include 'sqlconnect.php'; $sql = mysql_query("SELECT title FROM aktiviteter"); while ($row = mysql_fetch_array($sql)){ echo "<option value=\"owner1\">" . $row['title'] . "</option>"; } ?> </select> </body> </html>why dosnt this work?, if you cant see what i want to happen, ill post an explaination This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=307346.0 I am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - Code: [Select] <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> I am using PHP for CV Generator. I need to add an element for 'Add another' option, e.g. on employment section, if you have more than one job you may require to add another form. Would this work with PHP coding? If so, what is it called? If not so, maybe Javascript? I can google for it when I get a answer from you guys. By the way, you may be aware with this- I have a little experience with PHP coding. Dean Do I need to add value to this select statement? Code: [Select] <select id="expYear" name="expYear"> <option></option> <option>2011</option> <option>2012</option> <option>2013</option> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> </select> Debbie I'm having the strangest thing happing. When posting a form i'm not getting the option value. Instead its posting my text field ie: <option name="1">text</option> Code: [Select] <?php $query = "SELECT id, name FROM locations ORDER BY name"; $res = mysql_query($query, $cid); while($a = mysql_fetch_array($res)) { echo "<option name=".$a["id"].">".$a["name"]."</option>"; } ?> Code: [Select] <?php The code thats grapping it: if($_POST['location']==""){ $location = ""; echo '<div class="message error">Please enter a <strong>Location</strong></div>'; }else{ $location = $_POST['location']; } ?> Can anyone see why? I have also tried it in html to see if its my php, but i get the same result I'm trying to create VIP zone, but I need to check if user has input correct username and password....I tried to make it work this way HTML Code: [Select] <form action="vipchat.php" method="post" /> Korisnicko ime: <input type="text" name="ime"/> Lozinka: <input type="password" name="lozinka"/> <input type="submit" value="Uloguj se"/> </form>php Code: [Select] <?php $imet = "komp"; $sifrat = "racun"; if ($_POST["ime"]==$imet)and($_POST["lozinka"]==$sifrat) echo "Tacno je"; else echo "Netacno je"; ?> But it gives me this error Code: [Select] Parse error: syntax error, unexpected T_LOGICAL_AND in C:\AppServ\www\adm\vipchat.php on line 16 how would i render this Code: [Select] <select name="state" value="<?php echo $state; ?>"> <option>Select a state</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="DC">District Of Columbia</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> </select> ok so below is the select option for my form i creatig should this select have the name 0f bday form of the three selects so that when i put it into a variable it could just be $birthday = $_POST = ['bday']; Code: [Select] <select class="drop" name="bday"> <option>Month</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select class="drop" name="bday"> <option>Day</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select class="drop" name="bday"> <option>Year</option> <option value="2011">2011</option> <option value="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select> I am adding to a shopping cart using sessions, when I add a product with a selected size it echoes the correct size as text but when applying it to my option boxes as selected, it just shows the last item in the select box. here is the code for the session variables <?php for ($basket_counter=0;$basket_counter<$_SESSION['ses_basket_items'];$basket_counter++) { $price=sprintf("%01.2f",$ses_basket_price[$basket_counter]); $quantity=$ses_basket_amount[$basket_counter]; $code=$ses_basket_stockcode[$basket_counter]; $itemID=$ses_basket_id[$basket_counter]; $name=$ses_basket_name[$basket_counter]; $image=$ses_basket_image[$basket_counter]; $size=$ses_basket_size[$basket_counter]; $sizechoice=$ses_basket_sizechoice[$basket_counter]; // create array from sizes and make the option box selections if ($sizechoice!="" && (!in_array($sizechoice, array('One Size', 'one size', 'free size', 'Free Size', 'Adjustable', 'adjustable')))) { // add size trigger $sizelist="add"; //create the array $sizepick=explode(",", $sizechoice); } else { $sizepick=$sizechoice; } // adjust gst for AU customers if ($country='AU') { $price=sprintf("%01.2f",($price*1.1)); $unit=sprintf("%01.2f",($price/$quantity)); } else { $unit=sprintf("%01.2f",($price/$quantity)); } ?> and this bit inside the same loop displayes the select box for size <?php if ($sizelist && $sizelist='add') { echo "<select name='size' id='size' style='vertical-align:middle;'>"; foreach($sizepick AS $sizes) { if ($sizes==$size) { echo "<option value='$size' selected='selected'>$size</option>"; } else { echo "<option value='$sizes'>$sizes</option>"; }} echo "</select>"; } else { echo $size; } ?> appreciate any help on this Hey guys, i have a small problemo. As you can see i have made an option list from 0 to 3. How can I put this optionlist in a for loop so I can save some place? I have found an example but I dont know how to integrate it in my php Example Code: [Select] for( $i = 0; $i < 4; $i++ ) { $optionlist .= "<option value=\"$i\">$i</option>\n"; } $optionlist .= "</select>\n"; Code: [Select] <?php $dranken = array("cola", "fanta", "bier", "koffie", "thee"); $prijzen = array("2", "2", "1.80", "2.20", "2.20"); $i = 0; echo "<table>"; while ($dranken[$i]) { $listnaam = $dranken[$i] . "_aantal"; $optionlist = "<select name= '$listnaam'><option>0</option><option>1</option><option>2</option><option>3</option></select>"; echo "<tr><td >" . $dranken[$i] . "</td>"; echo "<td>" . $prijzen[$i] . "</td>"; echo "<td>" . $optionlist . "</td></tr>"; $i++; } echo "</table>"; ?> thanks Good day all, I am really in need of some help here with my website. I am new to the php and mysql environs, but an avid supporter and learner. I have a problem making my drop down 'category' option to work - as in when I select an option from the drop down list, it should pull the data from the mysql database which works magically with the keyword searches, etc...its just the category search not working - below is the coding which I am working with currently: action=search.php method=get> Keyword : <input type=text name=k /> Category : <select name=b> <option value=0>All</option> <?php $connection = mysql_connect('127.0.0.1', 'vale_view', '8hw9er1' ); if (!$connection) { die ("Could not connect to the database: <br />". mysql_error()); } $db_select=mysql_select_db('vale_view'); if (!$db_select) { die ("Could not select the database: <br />". mysql_error()); } $query = "SELECT catid,catname FROM categories order by catname"; $result = mysql_query( $query ) or die('die'); if (!$result) { die ("Could not query the database: <br />". mysql_error()); } while ($result_row = mysql_fetch_row($result)) { echo "<option value=".$result_row[0].">".$result_row[1]."</option>"; } mysql_close($connection); ?> Hi, I am trying to take the concatenated option value from my form and send it via email broken into the individual pieces. For example, in my code to follow... the ID field is the key field that generates what you see in the drop down list (Date, Site, Price). What I want to be able to do is separate (or un-concatenate, for lack of a better word) the values $Date, $Site, $Price so when the customer receives the email it reads this way because right now it only gives me the ID field (RID) to send via email... Date: 5/29-6/3/11 Site: Carterville Price: $1150.00 .... Any ideas on how to do this? Here is the code from my form..... Code: [Select] <?php $q=$_GET["q"]; $con = mysql_connect('my-host', 'my_user', 'my_pwd'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="SELECT * FROM daterange WHERE DEND > DATE(NOW()) AND STATUS='A' AND MONTH = '".$q."' ORDER BY RID, DATE, SITE"; $result = mysql_query($sql); // Determine the number of reservation dates $number = mysql_numrows($result); // Create drop-down menu of reservation dates print "<font size=\"3\" face=\"Arial\"><b>Select Your Reservation:</b><br> <form action=\"resersend.php\" method=\"post\"> <select name=\"RID\"> <option value=\"\">Choose One</option>"; for ($i=0; $i<$number; $i++) { $RID = mysql_result($result,$i,"RID"); $DATE = mysql_result($result,$i,"DATE"); $SITE = mysql_result($result,$i, "SITE"); $PRICE = mysql_result($result,$i, "PRICE"); print "<option value=\"$RID\">$DATE, $SITE, $PRICE</option>"; } print "</select><p align=left><label><font size=\"3\" face=\"Arial\">First Name: <input type=\"text\" name=\"FNAME\" size=\"50\" maxlength=\"50\" tabindex=\"1\"<br>"; print "<p align=left><label>Last Name: <input type=\"text\" name=\"LNAME\" size=\"50\" maxlength=\"50\" tabindex=\"2\"<br>"; print "<p align=left><label>Address Line 1: <input type=\"text\" name=\"ADDR1\" size=\"50\" maxlength=\"50\" tabindex=\"3\"<br>"; print "<p align=left><label>Address Line 2: <input type=\"text\" name=\"ADDR2\" size=\"50\" maxlength=\"50\" tabindex=\"4\"<br>"; print "<p align=left><label>City: <input type=\"text\" name=\"CITY\" size=\"50\" maxlength=\"50\" tabindex=\"5\"<br>"; print "<p align=left><label>State (abbrev.): <input type=\"text\" name=\"STATE\" size=\"2\" maxlength=\"2\" tabindex=\"6\"<br>"; print "<p align=left><label>Zip Code: <input type=\"text\" name=\"ZIP\" size=\"5\" maxlength=\"5\" tabindex=\"7\"<br>"; print "<p align=left><label>Contact Phone Number: (<input type=\"text\" name=\"PHONE1\" size=\"3\" maxlength=\"3\" tabindex=\"8\""; print "<label>)<input type=\"text\" name=\"PHONE2\" size=\"3\" maxlength=\"3\" tabindex=\"9\""; print "<label>-<input type=\"text\" name=\"PHONE3\" size=\"4\" maxlength=\"4\" tabindex=\"10\"<br>"; print "<p align=left><label>Email: <input type=\"text\" name=\"EMAIL\" size=\"50\" maxlength=\"50\" tabindex=\"11\"<br>"; print "<p align=left><input type=\"submit\" value=\"Book Now!\" name=\"submit\">"; print "<input type=\"reset\" value=\"reset\" name=\"reset\"></form>"; // Close the database connection mysql_close($con); ?> ok this works fine and everything but when here when i try to let the admin changes stuff and goes to change the venue a list show appear and it does but when it save it save it as RBB FIELD <option value="RED BULL ARENA">RED BULL ARENA</option><option value="RBB FIELD ">RBB FIELD </option><option value="RED BULL ARENA">RED BULL ARENA</option> why does it do that?? HElp ANYONE Code Code: [Select] <?php if (isset($_GET['eid'])){ $newid = $_GET['eid']; $sqlCommand = "SELECT * FROM events WHERE id='$newid' LIMIT 1"; $out = mysql_query($sqlCommand); $row = mysql_fetch_assoc($out); $eventid = $row["id"]; $eventname = $row["eventname"]; $eventtype = $row["typeevent"]; $eventinfo = $row["eventinfo"]; $date = $row["date"]; $time = $row["time"]; $livetickets = $row["sale"]; $numtickets = $row["numtickets"]; $pricestudents = $row["studentsprice"]; $priceseniors = $row["seniorsprice"]; $priceadults = $row["adultsprice"]; $venues = $row["venue"]; $category = $row["category"]; $query = mysql_query("SELECT venuename FROM venue"); while ($row = mysql_fetch_array($query)){ $venues .= '<option value="' . $row['venuename'] . '">' . $row['venuename'] . '</option>'; } $form = "<form action='eevent.php' method='post' enctype='multipart/form-data'> <table> <tr> <td>REQUIRED FIELDS *</td> <td></td> </tr> <tr> <td>Event Name*</td> <td><textarea cols='17' rows='1' name='eventname' />$eventname</textarea></td> </tr> <tr> <td>Type of event*</td> <td><textarea cols='17' rows='1' name='typeevent' />$eventtype</textarea></td> </tr> <tr> <td>Event Inforamtion*</td> <td><textarea name='eventinfo' cols='40' rows='5'>$eventinfo</textarea></td> </tr> <tr> <td>Date</td> <td><input type='text' size='10' name='date' value='$date' /></td> </tr> <tr> <td>Time</td> <td><input type='text' size='10' name='time' value='$time' /></td> </tr> <tr> <td>When tickets go on sale</td> <td><input type='text' size='10' name='sale' value='$livetickets' /></td> </tr> <tr> <td>Number of Tickets Available </td> <td><input type='text' size='5' name='numtickets' value='$numtickets' /></td> </tr> <tr> <td><h4>Ticket Prices</h4></td> </tr> <tr> <td>STUDENTS</td> <td>$<input type='text' size='3' name='studentsprice' value='$pricestudents'/></td> </tr> <tr> <td>SENIORS</td> <td>$<input type='text' size='3' name='seniorsprice' value='$priceseniors'/></td> </tr> <tr> <td>ADULTS</td> <td>$<input type='text' size='3' name='adultsprice' value='$priceadults' /></td> </tr> <tr> <td>SELECT VENUE</td> <td> <select name='venue'> <option value='$venues'>$venues</option> </select> </td> </tr> <tr> <td>SELECT CATEGORY</td> <td> <select name='category'> <option value='$category'>$category</option> <option>FOOTBALL</option> <option>BASKETBALL</option> <option>HOCKEY</option> <option>DRAMA</option> <option>MUSIC</option> <option>DANCE</option> <option>VISUAL ARTS</option> </select> </td> </tr> <tr> <td></td> <td><input type='hidden' name='saveevent' value='$newid'/></td> <td><input type='submit' name='savechanges' value='Save Changes'/></td> </tr> </table> </form>"; echo "$form"; } if ($_POST['saveevent']){ $newid = mysql_real_escape_string($_POST['saveevent']); $eventname = mysql_real_escape_string($_POST['eventname']); $eventtype = mysql_real_escape_string($_POST['typeevent']); $eventinfo = mysql_real_escape_string($_POST['eventinfo']); $date = mysql_real_escape_string($_POST['date']); $time = mysql_real_escape_string($_POST['time']); $livetickets = mysql_real_escape_string($_POST['sale']); $numtickets = mysql_real_escape_string($_POST['numtickets']); $pricestudents = mysql_real_escape_string($_POST['studentsprice']); $priceseniors = mysql_real_escape_string($_POST['seniorsprice']); $priceadults = mysql_real_escape_string($_POST['adultsprice']); $venues = mysql_real_escape_string($_POST['venue']); $categorys = mysql_real_escape_string($_POST['category']); $sqlCommand = "UPDATE events SET eventname='$eventname', typeevent='$eventtype', eventinfo='$eventinfo', date='$date', time='$time', sale='$livetickets', numtickets='$numtickets', studentsprice='$pricestudents', seniorsprice='$priceseniors', adultsprice='$priceadults', venue='$venues', category='$categorys' WHERE id='$newid'"; $out = mysql_query($sqlCommand); echo "SAVE CHANGES COMPLETED!"; } ?> i have a basic html form with a drop down selection box with 2 options ('old' and 'new'). when you click one it swaps them round to you can click the other because it is an onchange event. <form action="<?php $_SERVER['self']; ?>" method="get"> <select name="Time" onchange="this.form.submit();"> <option value="New">New</option> <option value="Old">Old</option> </select></form> I have the following which fils a combo box with years from 1950 to 2100. This is the year box for the date of birth. Year <select name="year_select"> <?php for( $i=1950; $i<=2100; $i++ ) { echo "<option value=\"{$i}\" class=\"year\">{$i}</option>"; } ?> </select> I want it to automatically display the year that is in the database so instead of automatically displaying 1950 i want their birth year displayed which is $tab_info->user_dob_year. How would i go about this? i dont know where to start since im using a for loop to populate it. Evening People I have this drop downbox on a HTML page, it is populated from a PHP page, if the user makes a selection i want that selection to be retained once the page refreshed. What i have is while ($row = $db->sql_fetchrow($result)) { if(isset($_GET["REGION_FILTER"]) AND $_GET["REGION_FILTER"] = $row['region'] AND strlen($_GET["REGION_FILTER"]) > 0) //if($region_filter = $row['region'] AND strlen($region_filter) > 0) { $region_filter_options .= '<option value="' . $row['region'] . '" SELECTED>' . $row['region'] . '</option>'; } else { $region_filter_options .= '<option value="' . $row['region']. '">' . $row['region'] . '</option>'; } } REGION_FILTER is the ID of the option box The drop down box is populated from the database but i cant seem to get the selected bit working. Can someone help identify what i have done wrong ? regards |