Wayniac Posted April 26, 2010 Share Posted April 26, 2010 Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/ Share on other sites More sharing options...
Wayniac Posted April 26, 2010 Author Share Posted April 26, 2010 The forum format options are cutting it off at the end and not applying the second tags around them properly.. weird... Thats why its cut off Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048285 Share on other sites More sharing options...
ChemicalBliss Posted April 26, 2010 Share Posted April 26, 2010 Try [ php ] tags. If you want the value to show what is currently in the database, you need to find which one it is and add selected=selected. So: $options = array("Alabama","Alaska","Arizona"); foreach($options As $country){ echo("<option name='country' value='".$country."'"); if($country == $row['country']){ echo(" selected=selected") } echo(">".$country."</option>\n"); } $row would be the row returned from the database. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048294 Share on other sites More sharing options...
Wayniac Posted April 26, 2010 Author Share Posted April 26, 2010 Thank you very much for your post and my apologize for my lack in understanding what it is you exactly mean... I think I understand, but am uncertain of how to implement this change... Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048354 Share on other sites More sharing options...
ChemicalBliss Posted April 26, 2010 Share Posted April 26, 2010 the code i provided would create the country select box entirely. (Youmay need to modify it slightly to uit your mysql table structure). You can either use it as a template to copy it for each select dropdown, or you can tie it into a function, to save repeating code unnecessarily. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048357 Share on other sites More sharing options...
Wayniac Posted April 26, 2010 Author Share Posted April 26, 2010 I placed it within php tags but all I get is a print out of "United States", "Canada", and "United Kingdom"... Their not in any selection box... $options = array("United States","Canada","United Kingdom"); foreach($options As $bill_country){ echo("<option name=\"bill_country\" value=\"\".$bill_country.\"\""); if($bill_country == $row["bill_country"]){ echo(" selected=selected"); } echo(">".$bill_country."</option>\n"); } Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048373 Share on other sites More sharing options...
ChemicalBliss Posted April 26, 2010 Share Posted April 26, 2010 Look at what its outputting, its only outputting the option tags. You still need the select tags. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048376 Share on other sites More sharing options...
Wayniac Posted April 26, 2010 Author Share Posted April 26, 2010 I believe I might have it (thanks to you), I'll keep you updated with the progress, just trying to get it to keep its selection now. I placed it within the value of selection. Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048377 Share on other sites More sharing options...
Wayniac Posted April 26, 2010 Author Share Posted April 26, 2010 Hmmmm.... The array is working quite well now, but I can't seem to change the values. If I wish to edit a country and change it from United States to Canada, once I submit and go check, nothing has changed... Something is not getting accepted... <select name="bill_country" class="textBox_center" id="bill_country" style="min-width:200px;" value="<?php $options = array("United States","Canada","United Kingdom"); foreach($options As $bill_country){ echo("<option name=\"bill_country\" value=\"\".$bill_country.\"\""); if($bill_country == $row["bill_country"]){ echo(" selected=selected"); } echo(">".$bill_country."</option>\n"); } ?>"/> Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048383 Share on other sites More sharing options...
Wayniac Posted April 26, 2010 Author Share Posted April 26, 2010 Huh... That would explain a lot of my problems... Nothing at all is able to be edited... It seems nothing is will change so therefore is not being send from the database from the main_edit_admin.php. I compared it to my previous pages which work fine, it must be a syntax error... Could someone take a peek and see if they see any discrepencies? A second set of eyes could go a long ways since mine seems to read in a trance after the 6th pass... Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048403 Share on other sites More sharing options...
ChemicalBliss Posted April 26, 2010 Share Posted April 26, 2010 You dont put value properties inside a select tag. $result = mysql_query("UPDATE spreadsheet SET date='$date', invoice_num='$invoice_num',conf_num='$conf_num , fname='$fname', bill_add='$bill_add', bill_city='$bill_city', bill_zip='$bill_zip' bill_state='$bill_state' bill_country='$bill_country' ship_add='$ship_add' ship_city='$ship_city' ship_zip='$ship_zip' ship_state='$ship_state' ship_country='$ship_country' terms='$terms' item_num='$item_num' description='$description' quantity='$quantity' price='$price' amount='$amount' sh='$sh' total='$total' ccard='$ccard' color='$color' label='$label' email='$email' phone='$phone' order_date='$order_date' inv_total='$inv_total' inv_minus_sales='$inv_minus_sales' trees_sold='$trees_sold' trees_gifted='$trees_gifted' trees_comp='$trees_comp' unit_cost='$unit_cost' sub_total='$sub_total' tax='$tax' total_paid='$total_paid' payment_method='$payment_method' notes='$notes' date_sent='$date_sent' attn='$attn' seedlings='$seedlings' four_four='$four_four' hear_about='$hear_about' order_emp='$order_emp' comm_fname='$comm_fname' comm_lname='$comm_lname' comm_total='$comm_total' comm_date_paid='$comm_date_paid' WHERE spreadsheetid='$spreadsheetid' ",$connect); put your query into a variable: $query = "UPDATE spreadsheet SET date='$date', invoice_num='$invoice_num',conf_num='$conf_num , fname='$fname', bill_add='$bill_add', bill_city='$bill_city', bill_zip='$bill_zip' bill_state='$bill_state' bill_country='$bill_country' ship_add='$ship_add' ship_city='$ship_city' ship_zip='$ship_zip' ship_state='$ship_state' ship_country='$ship_country' terms='$terms' item_num='$item_num' description='$description' quantity='$quantity' price='$price' amount='$amount' sh='$sh' total='$total' ccard='$ccard' color='$color' label='$label' email='$email' phone='$phone' order_date='$order_date' inv_total='$inv_total' inv_minus_sales='$inv_minus_sales' trees_sold='$trees_sold' trees_gifted='$trees_gifted' trees_comp='$trees_comp' unit_cost='$unit_cost' sub_total='$sub_total' tax='$tax' total_paid='$total_paid' payment_method='$payment_method' notes='$notes' date_sent='$date_sent' attn='$attn' seedlings='$seedlings' four_four='$four_four' hear_about='$hear_about' order_emp='$order_emp' comm_fname='$comm_fname' comm_lname='$comm_lname' comm_total='$comm_total' comm_date_paid='$comm_date_paid' WHERE spreadsheetid='$spreadsheetid' "; Then you would query with the variable, and echo the query if there is an error: $result = mysql_query($query) or die($query."<br>".mysql_error()); Also add a print_r($_POST); to the top just to make sure its submitting the data. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/199726-dropdown-values-are-empty/#findComment-1048494 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.