PHP - Getting Data Based On A Dynamic Dropdown List
Hi,
I am hoping someone can help me out with a slight issue I have with php and mySQL. I have an ajax-powered form with a select (dropdown) field populated through a php function. Based on the user-selected values in this field, data is displayed on the webpage; i.e. selected value 1 returns values x and y on the page. I am now trying to call additional data (value z) from a different table in the same database, and as before, use the selected values from the dropdown to display the data. For some reason, value z is not changing according to the user-selected value. This is my code: [The function to populate the select field] Code: [Select] function kfl_get_funds_names() { $result = array(); $result['CDF'] = 'Crosby Dragon Fund'; $result['CPF'] = 'Crosby Phoenix Fund'; $result['AMZPIF'] = 'AMZ Plus Income Fund'; $result['KASBIIF'] = 'KASB Islamic Income Opportunity'; $result['KASBCPGF'] = 'KASB Capital Protected Gold Fund'; $result['KASBLF'] = 'KASB Income Opportunity Fund'; $result['KASBCF'] = 'KASB Cash Fund'; $result['KASBBF'] = 'KASB Asset Allocation Fund'; $result['KASBSMF'] = 'KASB Stock Market Fund'; return $result; } [the code calling and using the function to interact with the database] Code: [Select] $funds_to_display = kfl_get_funds_names(); $current_symbol = key( $funds_to_display ); $current_nav_rates = kfl_get_latest_rates( $current_symbol ); [the code calling additional data, value z, from the database, and using the info in the select field to filter it] Code: [Select] $cutoff = kfl_cutoff( $current_symbol ); The display of each of these items is as follows: Code: [Select] <?php echo $current_nav_rates['nav_date']; ?> <?php echo $funds_to_display[$current_symbol]; ?> <?php echo $cutoff['cutoff']; ?> I can't get the $cutoff code to display the correct values. It picks up the first symbol to display and doesn't change with user selection. The code for the selection box, by the way: Code: [Select] <select id="dailynav-funds" autocomplete="off" name="dnf"> <?php foreach ($funds_to_display as $fund_symbol => $fund_name) { echo '<option'; if( $fund_symbol == $current_symbol ) { echo ' selected="selected"'; } echo ' value="' . $fund_symbol . '">'; echo $fund_name; echo '</option>'; } ?> </select> I've tried to get data using $_GET['dnf'] into the cutoff code, but that throws up parse errors. What am I doing wrong, and how can I resolve this issue? Thanks in advance! Similar TutorialsHello,, I have looked for numerous examples, and have only got part of the answer. I have successfully populated a drop down list by reading the database. It populates with a list of quest titles. Once the user selects the quest. I want a textbox to populate with the Quest Description. I found an example that uses AJAX/PHP to do this, but it doesn't access a db to read/populate. The main code is in index.html The original example you select a country, and it populates a text field with the currency code. It passes a variable called $country to another file called find_ccode.php. I changed the first case in find_ccode.php to access my database, and populate the text box with quest description. Ideally I will like to make this case dynamic based off QuestID, would populate textbox with corresponding Quest Description (QDescrip). I then tried the other way in index.php I dynamically populated the dropdown list, and gave the option values the QuestIDs to be passed to $country, but something isn't working. I have a write files command to let me know what the $country variable is passing, and it never writes. It works in index.html though. I apologize in advance for my amateurish coding. I still have a lot to learn. I have included the code below, but if you know a more elegant way of doing it. I am creating a role-playing game, as you probably have figured out by now. I hope to one day put it on the web, but right now using it as a way of learning html, and PHP. I really want to know how to catch the value of the dropdown box. I would like to know what it is before sending over. also what is this.value. I assume this is what the value of the dropdown box is when you have selected something. I have been beating my head for days trying to figure this out. Any help is very much appreciated! Index.html <html> <head> <title>Changing textbox value based on dropdown list using Ajax and PHP</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> // Developed by Roshan Bhattarai // Visit http://roshanbh.com.np for this script and more. // This notice MUST stay intact for legal use //fuction to return the xml http object function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCurrencyCode(strURL) { var req = getXMLHTTP(); if (req) { //function to be called when state is changed req.onreadystatechange = function() { //when state is completed i.e 4 if (req.readyState == 4) { // only if http status is "OK" if (req.status == 200) { document.getElementById('cur_code').value=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> </head> <body style="font: 12px Verdana, Arial, Helvetica, sans-serif;"> <form style="text-align:center" method="post" action="" name="form1"> <p style="color:#000099 ">When you change the dropdown list, the respective currency code of the country will be displayed in the textbox which is fetched from PHP using Ajax. </p> <p>Country : <select name="country" onChange="getCurrencyCode('find_ccode.php?country='+this.value)" <?php mysql_connect('localhost', '$user', '$password'); mysql_select_db('sok'); $result = mysql_query('select QuestID,QTitle, QDescrip from QuestList'); $options=""; while ($row=mysql_fetch_array($result)) { $QuestID=$row["QuestID"]; $QTitle=$row["QTitle"]; $options.="<OPTION VALUE=\"$QuestID\">".$QTitle; } ?> <option value="">Select Country</option> <option value="1">USA</option> <option value="2">UK</option> <option value="3">Nepal</option> </select><br/><br/> Currency : <input type="text" name="cur_code" id="cur_code" ></p> </form> </body> </html> Index.php <html> <head> <title>Changing textbox value based on dropdown list using Ajax and PHP</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script> // Developed by Roshan Bhattarai // Visit http://roshanbh.com.np for this script and more. // This notice MUST stay intact for legal use //fuction to return the xml http object function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCurrencyCode(strURL) { var req = getXMLHTTP(); if (req) { //function to be called when state is changed req.onreadystatechange = function() { //when state is completed i.e 4 if (req.readyState == 4) { // only if http status is "OK" if (req.status == 200) { document.getElementById('cur_code').value=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> </head> <body style="font: 12px Verdana, Arial, Helvetica, sans-serif;"> <form style="text-align:center" method="post" action="" name="form1"> <p style="color:#000099 ">When you change the dropdown list, the respective currency code of the country will be displayed in the textbox which is fetched from PHP using Ajax. </p> <p>Quest : <select name="country" getCurrencyCode('find_ccode.php?country='+this.value)">' <?php mysql_connect('localhost', '$user', '$password'); mysql_select_db('sok'); $result = mysql_query('select QuestID,QTitle, QDescrip from QuestList'); $options=""; while ($row=mysql_fetch_array($result)) { $QuestID=$row["QuestID"]; $QTitle=$row["QTitle"]; $options.="<OPTION VALUE=\"$QuestID\">".$QTitle; } $myFile = "test_catchoption.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $options); fclose($fh); ?> Choose your Quest <?=$options?> </SELECT> <br/><br/> Quest Description : <input type="text" name="cur_code" id="cur_code" ></p> </form> </body> </html> find_ccode.php <?php // Developed by Roshan Bhattarai // Visit http://roshanbh.com.np for this script and more. // This notice MUST stay intact for legal use $country=$_REQUEST['country']; $myFile = "testFilefindcc.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $country); fclose($fh); switch($country) { case "1" : mysql_connect('localhost', '$user', '$password'); mysql_select_db('sok'); $result = mysql_query("select * from QuestList where QuestID = '1'"); $row = mysql_fetch_assoc($result); echo $row['QDescrip']; break; case "2" : echo "GBP"; break; case "3" : echo "NPR"; break; } ?> please help me the concept or code to retrive data from the database and display data according to the data from the dynamic list box option. Hi? im just a beginner in php i just want to ask how to insert a data into a table from a dropdown list. I have concatenate the itemid and description to form the dropdown list. But when i viewed my item_table the itemid and description columns are null. can you help me with this.. this is my php code for the dropdown list... <?php $query = "SELECT CONCAT(itemid,' ', '-',' ', description) AS Item FROM item_table"; $result = mysql_query($query) or die(mysql_error()); $dropdown = "<SELECT CONCAT(itemid,' ' '-',' ', description) AS Item FROM item_table>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['Item']}'>{$row['Item']}</option>"; } $dropdown .= "\r\n</select>"; echo $dropdown; ?> this my code for inserting data into the item_table... <?php if(isset($_POST ['submit'])) { $itemid = $_POST['itemid']; $description = $_POST['description']; $datein = $_POST['datein']; $qtyin = $_POST['qtyin']; $unitprice = $_POST['unitprice']; $unit = $_POST['unit']; $category = $_POST['category']; $empid = $_POST['empid']; $message =''; if(($itemid && $description == "")||($itemid && $description == null)) { header("location:IncomingEntry.php?msg=Incorrect"); exit(); } else { $link = mysql_connect('localhost', 'root', '') or die(mysql_error()); $db_selected = mysql_select_db('inventory', $link); $message=''; $query = "INSERT INTO incoming_table (itemid , description, datein, qtyin, unitprice, unit, category, empid) VALUES ('".$itemid."', '".$description."', '".$datein."', '".$qtyin."', '".$unitprice."', '".$unit."', '".$category."', '".$empid."')"; if (!mysql_query($query,$link)) { die('Error: ' . mysql_error()); } header("location: IncomingEntry.php?msg=1 record added"); } } ?> I have a form created with code already written. I am in need of a push in the right direction or a potential tutorial on this issue i have. I am running a fanatsy golf website where the user will pick one golfer each week and the cannot select them again. Is there a way I can remove that data from the list for the next week when the user makes his selection or can I have that data another color and unselectable. If you want code, please let me know and i can provide it. Thanks in advance for your help. p.s. the list data is stored in a MySQL database. Hi , I have one question .. Can I split showing of content of dynamic list in 2 parts , when I echo list in code .. Code: [Select] <?php // Run a select query to get my letest 8 items // Connect to the MySQL database include "../connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 8"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="2" cellspacing="2" cellpadding="2"> <tr> <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="2" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> </tr> </table>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Code: [Select] <p><?php echo $dynamicList; ?><br /> </p> It works ok, and putting my files, everything works, but when I put 8 pictures with price and other details, it just show one image with details and another image below with details, and the third image below and so on .. Can I split dynamic list to show 4 images with details on the left side and 4 on the right side? Thank you in advance for help , if is possible I have two tables. Table Name:Users Fields: User_name user_email user_level pwd 2.Reference Fields: refid username origin destination user_name in the users table and the username field in reference fields are common fields. There is user order form.whenever an user places an order, refid field in reference table will be updated.So the user will be provided with an refid Steps: 1.User needs to log in with a valid user id and pwd 2.Once logged in, there will be search, where the user will input the refid which has been provided to him during the time of order placement. 3.Now User is able to view all the details for any refid 3.Up to this we have completed. Query: Now we need to retrieve the details based on the user logged in. For eg: user 'USER A' has been provided with the referenceid '1234' during the time of order placement user 'USER B' has been provided with the referenceid '2468' during the time of order placement When the userA login and enter the refid as '2468' he should not get any details.He should get details only for the reference ids which is assigned to him. <?php session_start(); if (!$_SESSION["user_name"]) { // User not logged in, redirect to login page Header("Location: login.php"); } $con = mysql_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $user_name = $_POST['user_name']; $refid = $_POST['refid']; $query = "SELECT * from reference,users WHERE reference.username=users.user_name AND reference.refid='$refid' AND "; $result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query); while($row = mysql_fetch_array($result)) { echo $row['refid']; echo $row['origin']; echo $row['dest']; echo $row['date']; echo $row['exdate']; echo $row['username']; } echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> <html> <form method="post" action="final.php"> Ref Id:<input type="text" name="refid"> <input type="submit" value="submit" name="submit"> </html> Hi guys. I am having a hard time finding a solution for this, is it possible to get not the value of a dropdown (oh what's it called??? ) but what is in between of the <option> tag?like, Code: [Select] <select name="catID"> <option value=$row['c_id']>$row['c_name']</option> and save it to the database??cuz I'm using a dynamic dropdown which bases the content of another dropdown by the id of the previous. And so, if i save it to the database, instead of for example "BSA" is saved, the id of "BSA" which is "1" is saved..any ideas guys? Hi guys, I've got this php script which display the users of my database in a dynamic dropdown: <?php include "leadscript/connect_to_mysql.php"; $canvass_name=""; $sql = mysql_query("SELECT * FROM csj_canvasser"); $appointmentCount6 = mysql_num_rows($sql); // count the output amount if ($appointmentCount6 > 0) { while($row = mysql_fetch_array($sql)){ $c_employee = $row["c_employee"]; $canvass_name .='<option value="' . $c_employee . '">' . $c_employee . ' </option>'; } } ?> <form> <select name="c_employee"> <option value="">Select a person:</option> <?php echo $canvass_name; ?> </select> </form> I was wondering if there's a way I can write a code to GET value I select from the dynamic dropdown and use it to write a select query. Thank Hey guys, I am wanting to select a dropdown value based on the value of 'level' in the row of the user select by a $_GET. It will house the ranks of the user. Here is my script. RANK <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); $result = mysql_query("SELECT * FROM users WHERE user_id = '$_GET[id]'"); $row = mysql_num_rows($result); ?> <form id="main_form" name="main_form" method="post" action=""> <select name="rank"> <option value="0" <?php if($row['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($row['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($row['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($row['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($row['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($row['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($row['level']=="6") { echo "selected"; }?>>Owner</option> </select> <input type="submit" id="main_submit" name="main_submit" value="submit" /> </form> It is not selecting for some reason at all. Can someone tell me what I am doing wrong? The rest of my coding works however this part does not and I'm trying to figure out why. I'm sure my syntax isn't right so I hope someone can correct my mistake. $contentpageID = $_GET['id']; $query = "SELECT contentpages.contentpage, contentpages.shortname, contentpages.contentcode, contentpages.linebreaks, contentpages.backlink, contentpages.showheading, contentpages.visible, contentpages.template_id FROM contentpages WHERE contentpages.id = '" . $contentpageID . "'"; <label for="template">Template</label> <select class="dropdown" name="template" id="template" title="Template"> <option value="0">- Select -</option> <?php $query = 'SELECT * FROM templates'; $result = mysql_query ( $query ); while ( $template_row = mysql_fetch_assoc ( $result ) ) { print "<option value=\"".$template_row['id']."\" "; if($template_row['id'] == $row['template_id']) { print " SELECTED"; } print ">".$template_row['templatename']."</option>\r"; } ?> </select> Hi everyone, I've read through the FAQs for Dynamic Dropdown Menus on this site, as well as others, and I can't figure out why my code won't work. I have two dropdown boxes that need to be populated with data from a mysql table; one menu for route types, and one for route numbers. When I choose the route from the 'Route' menu, the 'Number' menu automatically populates with all of the possible numbers, rather than only those that correspond with the route type. I can tell that the problem has something to do with the value of 'Route' not being recognized, but I don't know why. I'm a beginner when it comes to PHP, so any suggestions or help would be much appreciated! Thanks! The code is as follows: Code: [Select] <html> <body> <basefont face='calibri' color='#7E2217'> <?php // set variables $mileTable = $_GET['mileTable']; $routeType = isset($_POST['Roadtype'])? $_POST['Roadtype']: 0; include 'opendbMile.php'; include 'error.php'; // Connect to the MySQL DBMS if (!($connection = @ mysql_connect($hostName, $username, $password))) die("Could not connect"); if (!mysql_select_db($databaseName, $connection)) showerror( ); // Start a query... $query = "SELECT ID, Roadtype FROM Alabama GROUP BY Roadtype"; // execute the SQL statement $result = mysql_query($query, $connection) or die(mysql_error()); echo '<form name="mileform" method="post" action="MileQuery.php">'; echo '<p>Route: <select name="routeType" id="routeType" onchange="this.form.submit();"> <option value="0"'.($routeType == 0? ' SELECTED': '').'>Route</option>'; while($row = mysql_fetch_array($result)){ echo ' <option value="'.$row[0].'"'.(($routeType == $row[0])? ' SELECTED': '').'>'.$row[1].'</option>'; } echo ' </select> </p>'; // create the SQL statement $query2 = "SELECT ID, Roadnumber FROM Alabama GROUP BY Roadnumber"; if($mnucategory != 0){ // Filter road numbers $query2 .= " WHERE Roadtype='".$routeType."'"; } // execute the SQL statement $result2 = mysql_query($query2, $connection) or die(mysql_error()); echo '<p>Number: <select name="routeNumber" id="routeNumber" onchange="this.form.submit();"> <option value="0"'.($routeNumber == 0? ' SELECTED': '').'>Number</option>'; while($row2 = mysql_fetch_array($result2)){ echo ' <option value="', $row2[0].'"'.(($routeNumber == $row2[0])? ' SELECTED': '').'>'. $row2[1], '</option>'; } echo ' </select> </p>'; // Close the DBMS connection mysql_close($connection); ?> </form> </body> </html> I want make the following, (I have already a database with three tables (Countries, Timeline and Category)). 1: list of countries (drop down menu 1), Timeline of the countries history (drop down 2) and Category (drop down 3). 2: The selected values of the drop down menus must show take the information from the database. Can any one help me with the coding? Working on a site with a couple hundred virtually identical landing pages to maximize SEO. Rather than hard code the pages, I am wondering if there is a way to have one page that handles all the url's and dynamically codes and loads with title, keywords, content & alt tags all specific to the particular url requested. Seems like the challenge is doing it in a way that does not constitute a redirect. Is it better to do this in the .htaccess? Hi all, here's my code: Code: [Select] <?php foreach ($_SESSION['topping'] as $value) { echo "<tr><td width='30%'>Topping</td><td width='50%'>$value</td><td width='20%'><select name='notopping'>"; foreach ($_SESSION['cupcake'] as $number) { '<option name="notoppings[]" value="'.$number.'">".$number."</option>'; } echo "</select></td></tr>"; } ?> $_SESSION['cupcake'] is a value from either 6, 12, 24 or 36. What I want to do is put them into a drop down box (second foreach) as the value and the displayed value - counting up from 1 (so 1,2,3,4,5,6 or up to 12,24 etc). Also by creating this as an array, does this mean than for each topping (say Vanilla and Chocolate) the value dynamically created can be used on the next page by using $_POST['notoppings'] to display each type (two different numbers - one for Vanilla and one for Chocolate). Does that make sense? Thanks! Jason I have 10 tables in my database. I want load these 10 table names into a drop-down list. If a user selects a value form the drop-down list, a form should be displayed with related to the table. (form fields should be appropriate table's column headers) When user fill the form and submitted, data should be saved in the selected table. Give me a code example to do this. I'm new to this form and php/mysql so sorry if this isn't the right place to post this. This is what is in the first dropdown box. Code: [Select] $selValues['john'] = "a, b, c, d, e"; These are the different lists I want it to put in the second drop down box depending on what they choose in the first. Code: [Select] $selValues['list1']= " a1, a2, a3, a4, a5"; $selValues['list2']= " b1, b2, b3, b4, b5"; This is how I made an attempt to make it work before posting here. Along with plently of other ways. Code: [Select] if ($selValues['john']=a) { $chan_input = selectBuilder($selValues['$list1'] }; else if ($selValues['john']=b) { $chan_input = selectBuilder($selValues['$list2'] }; Basicly how I need it to work is there are two drop down boxes. First they will chose between a,b,c,d,e. If they chose a then on the second drop down box I only want them to be able to select a1,a2,a3,a4,a5. Hi all, firstly apologies as this is a cross post from another forum and we have hit a block.. I am hoping that opening this up to another set of gurus we can get a resolution. What I am trying to achieve is this... I have 2 tables Main and FinancialYear. Main holds all data which I use a form to post the data to it..(all works fine). I use this code to create a drop down in the insert.php form. again this works. Code: [Select] <tr><td>Financial Year: xxxx/xxxx</td><td> <!-- pulls the data from the table variable to populate the dropdown menu --> <?php $database = 'Projects_Main'; $fintable = 'FinancialYear'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database 'cos somethin' is wrong"); if (!mysql_select_db($database)) die("Can't select database"); $result = mysql_query("SELECT FinancialYear_id, FinancialYear FROM {$fintable} order by FinancialYear"); $options=""; while ($row=mysql_fetch_array($result)) { //$id=$row["FinancialYear_id"]; $thing=$row["FinancialYear"]; $options.="<OPTION VALUE=\"$thing\">".$thing.'</option>'; } ?> <SELECT NAME="FinancialYear"> <OPTION VALUE=0>Choose</OPTION> <?=$options?> </SELECT> </td></tr> What I have done is built another form which list all records in the database and creates an update url for every record that passes the field Project_id where i use $_get to retrieve the Project_id to retrieve the relevant data into the update.php form. I am able to populate the form with all the correct information BUT I am looking to introduce some dropdowns to aid updating the data and provide consistency to the data. . Code: [Select] // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db('Projects_Main')or die("cannot select DB"); // get value of id that sent from address bar $Project_id=$_GET['Project_id']; //define vars $FinancialYear=$_POST['FinancialYear']; // other vars defined here also.. about 30 // Retrieve data from database $sql="SELECT * FROM Main WHERE Project_id='$Project_id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> //update_record_ac.php posts the data to the dbase. <form name="form1" method="post" action="update_record_ac.php"> <center> <table> <tr><td><b>Store Details<b></td></tr> <tr><td>Financial Year:</td><td> // takes the data from $rows and present to form <input name="FinancialYear" type="text" id="FinancialYear" value="<?php echo $rows['FinancialYear']; ?>"> // this is where I need to create the drop down.. see my other comments in the post..... </td></tr> the financialYear table consists if the following; financialyear_id - pri, auto inc. ---- data format is 2010/2011, 2011/2012.... financialyear the main table contains 30 fields .. won't list em all... Project_id - pri, auto inc financialyear I need the drop down to pull the data from the financialyear table and then to present or focus on the currently stored data... so if the store value in the table Main is 2010/2011 if Ii was to select the update url in the list_record.php it will pull all the relevant data into update_record.php form. the financialyear field in the form should be a dropdown with all the financial years listed but the 2010/2011 is selected or focused. I still need to be able to change the entry and post this back to the table Main..... So the dropdown contains the list of years from the financialyear table but when the record is pulled from table main the year that is stored in table Main should be highlighted in the dropdown and I should be able to select a new record and post back to the table Main.. any thoughts... please don't slate for the cross post, I haven't sanatised the data at any stage. I know i'm open to injection attacks. and yes my code is a little dirty... all these will be rectified as i finalise the process and ensure the consept works. Thanks for taking the time to read and hopefully you are able to understand the requirement and are able to assist. thanks Balgrath |