Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Drop-down Displaying MySQL Data
I've got this dropdown trying to call the data in...basically, I only want it to show if it is an upcoming event. Past events are hidden away in the archives. I can get it to work if I remove the if ($row['date'] etc, but not with it in. Can anyone spot any errors with my code? Code:
2 Drop Down List Where Need Query Database
there is drop down list box linked to the database where it displays the state of a country and once the user clicks on the particular state, there purpose to be radio button displaying the locations available of that state, the location displayed in radio buttons are from the database. currently the source code i'm using is (which uses a submit button to query the database but i does not want the submit button it purpose to work using Code:
Saving/Loading Data In Drop-down List
I have a drop-down list with set values. When there is a corresponding value in my database when the page loads I want the drop-down list to pick the appropriate value from the list. Instead it always defaults to the first value. Can anyone give me an example of how to do this? Also, one time after adding a variable to a classes file this symbol:  started showing up on all of my pages. Has anyone seen this before? I can't find any information on the web about it.
Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing <select name=categories> <? $cat_array = get_categories(); foreach($cat_array as $this_cat) { echo "<option value=""; echo $this_cat["category_id"]; echo """; echo ">"; echo $this_cat["category_name"]; echo " "; } ?> </select> ========================================================== function get_categories() { //get the list of categories from the database $conn = mysql_pconnect("localhost", "user", "pwd"); $query = "select * from categories"; $result = mysql_query($query); if(!$result) return false; $num_cats = mysql_num_rows($result); if($num_cats == 0) return false; $result = db_result_to_array($result); return $result; } //A function that returns a query to the database as an array function db_result_to_array($result) { $res_array = array(); for($count=0; $row=@mysql_fetch_array($result); $count++) $res_array[$count] = $row; return $res_array; }
Entering Data From A Form To A Mysql Database
I'm trying to enter data from a form with the fields name and email into a mysql database called newsletter, as you guess it's a newsletter sign up. this what I have at the moment: Code:
Insert Data From Form To MySQL Database
I have run createTable.php and everything is created. Now I want to run insertData.php. I want the user to enter stuff in the form & everything must be fill in before they click the submit button. It will call submitData() & all the information was enter will insert into the database. PHP Code:
Populate A Drop Down List In A Form On The Basis Of A First Selection
I have developed a form to register a property in a db. The form needs the selection of a country and then based on that selection the selection of regions from the selected country. I have a program which allows selection of a country and then a region but it uses java script which I would like to avoid. I also just wanted one submit button if possible. Code:
2 Drop Down List Using MYSQL
I have a model table with the following fields: MODEL_ID, MAKE_ID, NAME. And a make table with the following fields: MAKE_ID, NAME. The first drop down list (make) to select a make of a car i.e. Chevrolet, Ford. When a make is selected, then all the model for that paticular make appear in the second drop down list.
PHP And MYSQL Drop Down List
I need a script to create a drop down list which has vehicle makes. The vehicle make list should feed a vehicle model list so when I select a make all the models for the make appear in the model list. I have a make table which has MAKE_ID, make NAME and a model table which has MODEL_ID, MAKE_ID and model NAME. I tried using a script using javascript array but wherever I have a query that pulls the NAME from the database there's always a carriage return after the NAME which messes up the javascript array. I'd rather do it all with PHP if possible. If not please give me one that works and I don't have to spend hours troubleshooting.
Multiple Drop Down List Problem And MySQL
I am trying to populate around 30 drop down lists via a single query to a mySQL database. The problem is how to make sure that each drop down list only display it's relevant data. for example the table is as follows:
Displaying Data In A Editing Form
I have a form that has three checkboxes. A,B&C. Data from A & C has been entered into the database by serializing it.I now want to create a edit form where the user can view his choices ticked. <form action="postoDb.php"> A<input type="checkbox" name="Choice[]" value="A"> B<input type="checkbox" name="Choice[]" value="B"> C<input type="checkbox" name="Choice[]" value="C"> </form> //postodb.php $bn = serialize($Choice); sql ="insert into table (choice) values('$bn')";
How To Grad Information From Mysql Database With Drop Down Menu's?
i am trying to do is like this website http://www.chippeduk.com/ in the search area (bottom right), where the user selects a make (all fields grab from the database), then selects a model, then they select the fine tune, then they click search this will bring up the information about the car they have chosen. How would i do this, would i use multiple tables and then link them together via an id? i am new to PHP/MySQL but very willing to learn.
PHP MySQL Query Not Displaying Data
I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the new values are updated in all corresponding tables (the function of the pages in question). However, on the page that does the DB update, I also want to do some checks on the data before performing the update. Now, the problem that I am running into is that when I don't update the primary key field (keyid) the page is running into the section where it displays a message that the keyid already exists. This only happens when the keyid on the previous page is not changed. Upon troubleshooting the problem I found that the very first SELECT statement does not seem to be returning any rows despite the fact that the statement, when run on the SQL server, returns exactly one row. If any could provide some assistance with this matter, I would be most appreciative. Code: <?php session_start(); header("Cache-control: private"); //IE 6 Fix //continue if authenticated if ($_SESSION['auth'] == 1) { //get variables from post $keyid = $_POST['keyid']; $username = $_POST['username']; $corpid = $_POST['corpid']; $usergroupname = $_POST['usergroupname']; $oldkeyid = $_POST['oldkeyid']; $oldcorpid = $_POST['oldcorpid']; echo("Keyid: $keyid"); // Connect to MySQL mysql_connect ("address.com", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error()); //select database on server mysql_select_db ("seniorproject"); //SQL Statement $sql = "SELECT keyid, corpid FROM users WHERE keyid='".$keyid"'"; // Execute the query and put results in $result $result = mysql_query( $sql ) or die ( 'Unable to execute query.' ); echo mysql_result($result,0); // Count number of matches and print to screen $numrows = mysql_numrows( $result ); if ($numrows == 1) {echo(" SQL Query: $sql"); $result_ar = mysql_fetch_row($result); $result_ar = mysql_fetch_row($result); $dbkeyid = $result_ar['keyid']; $dbcorpid = $result_ar['corpid']; echo("<br> CorpID: $corpid <br>"); echo(" DBCorpid: $dbcorpid <br>"); echo(" DBKeyID: $dbkeyid <br>"); if($dbcorpid == $oldcorpid) { //If this condition is true, then KEYID has not changed. Execute code // Formulate the query $sql = "UPDATE users SET corpid = '".$corpid."', username = '".$username."', usergroup = '".$usergroupname."', keyid = '".$keyid."' WHERE keyid = '".$oldkeyid."'";........
Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it, there are some things with which I am confounded! What I'm trying to do is read in a Date from a mySql database and then display it on screen (the Date is in the usual yyyy-mm-dd format). If I use SQL on phpadmin SELECT Date FROM details WHERE details.Name = "Paul Lee" LIMIT 0 , 30 The result comes up 2005-01-01, so this seems to work. But if I use the following: $db = mysqli_connect("localhost","root",""); @mysqli_select_db($db, "personnel") or die ( "Unable to select database" ); $query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee" LIMIT 0, 30' $result=mysqli_query($db, $query); echo "<br>"; echo $result; mysqli_close($db); I get "Object id #2" displayed on screen. I have tried to use the explode function to separate the months, year and day using the "-" as a delimeter, but this doesn't work, and I can't seem to get the other php date/time functions to work either.
Displaying Block Of Text From MySQL Database
I would like to create a details.php page that displays all my products. I understand how to get the title, price, description etc from mySQL. But my problem is how do I get a list of data? For example say I want to display the features of a product in point form (list). What is the best way to do this? How do most common websites do this? Code:
Displaying Line Breaks From MySQL Data
when i retrieve data from a MySQL database which i have put line breaks in they do not show in html, i understand that this is because HTML ignores spaces unless they are formatted as i know i could use the <pre> tag to show it as it was given, which removes all styling from the text, i need to convert the breaks in MySQL into <br> or <br><br> (to start a new paragraph)
List Mysql Data Using Php With Sub Headings?
i've got a database table storing products for a hire company, the database is a copy of their brochure so i'm sorting by page sections so link to section 4 reads /product.php?page=4 Code:
Simple A-Z Link List For Searching Mysql Database
I'm trying to set-up a simple A-Z list so that people can search a mysql database by each letter. Click on "A" get all records in the DB that start with "A". I have it working no problem but i want to be able to add "#" so that the user can get all records that start with a Number. For some reason the query i'm running won't grab any records that start with a number? here is the query:
Form Data Not Stored In DataBase
I was trying setting up these scripts following instructions in a book from 2003, so I thought maybe some of the code might be outdated. Basically this is what Is supposed to happen: 1.- Display a form, enter details into fields and click submit. 2.- After having clicked on submit you're redirected to another page that will display the entered values and store them in the MySQL DB specified. Now what happens is that no errors are displayed after clicking on the submit button in the form, but neither are the entered values. In PHPMyAdmin I can see that the Db is still empty. I created a total of 3 files that reside in the same folder: The form, that when clicking on submit is redirected to the next file: Code:
Form Data Not Stored In Database ?
This is the code for a Returns form where I am trying to implement these validations: 1. Check if fields aint empty 2. Check if SESSION_username = username from Customer table and get customer ID use that Customer ID to look up Orders table and find if the ORDER NO. that has been entered is = an order no. in the Orders table i.e. see if the oder no. entered was actually an order placed by the user b4 * Customer table has cust id and username. Order table has only cust ID. returns table will store username from Session so that it can display each user's individual returns. Code:
Comparing Form Data To Mysql Data
Im interested in building a script that would take form data, a variable like an address, and compare it with a known address in a mysql table (called addresses), then if there is a match log the address information in a separate table called (addresslog), and return the visitor to a certain page. If there is no match between the address entered in the form and known addresses then the information is still logged into the addresslog database but the visitor will be sent to a different page. I'm still new to this, and am working through the logic and the syntax, but I believe I'm close. It's still not working, I have all of the proper tables, maybe I'm way off with the coding so I thought I would seek out some expert advice. Here's the entire script with as much explanation as I could give. PHP Code:
Drop Down Not Displaying All Rows
I am having an issue with the drop down box. If there is only one row in the table the drop down box will display nothing. once the table has two or more rows the drop down displays the row but always one shy of the total. here is the script i am using: $query = "SELECT SEC_TITLE FROM section WHERE SEC_TITLE != ''"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<form action='#'> <select name=section> "; while ($line = mysql_fetch_array($result, MYSQL_NUM)) { $section = $line[0]; echo " <option value=$section>$section "; } }
Drop Down List
I want to read a directory for available files and then get the filenames and put them in a drop down list. Whatever the user will select will be the value of the variable $selected. I already found the code to read directories: Code:
Php And Drop Down List
I am coding an email form on a site. A user enters their name and contact email and then selects from a drop down list to which particular email the message should be sent: User1, User2, User3. Then the user types out a message and hits submit. My problem is that I am unsure as to how to grab the selection in the drop down list and pull the selection and place it like this: "$selection@domain.com". Here is the php code:
Drop Down Box To A List Box
i have this drop down box that displays the relevant info from the table that its loading. But the drop down box isn't quite so wise to use if there hundreds of rows. So what i wanted to do was change it to a list box instead ... would any one know how to do that? Code:
A Dynamic Drop Down List
I need to create a dynamic drop down list. By this i mean that the webpage html form = select style will recieve all the values as based on a query to a mysql database. I have no problems quering the data base with PHP, But i need to make some kind of for loop that will add a new value to the selct form for each result from the database. my thought process go like this. 1. call data base to guery. (no problem) 2. make variable variables that will be created according to the number of results (these variables must be created according to results of query, not a problem i think) 3. make a form like this <form action = ***** method = post> <select name = ******> <option value = "This is a query result"> This is a query result> //This is the part i need to using a for loop and variable variables </select></form> so my problem is part 3, cause is this all done in PHP, or if i had all these variables, can i do this in HTML? Can i make a for loop in PHP that would break into HTML during these parts?
Very Simple Drop-down List...
Hi! I'm having a problem with a very simple drop-down list since the page comes out with no elements in the drop-down but giving no errors. This is the code: <form name="year_search_form" method="post" action="results.php"> <select name="select_year" id="select_year"> <? $query="SELECT * FROM table ORDER BY year"; $result = mysql_query($query) or die ("Error in query: $query. " ..mysql_error()); while ($line = mysql_fetch_array($result)) { print ("<OPTION value=".$line['year']."></OPTION>"); } ?> </select> </form>
Drop Down List From An Array
I want the array to contain a valid year of birth for anyone between the ages of 16 and 80. I'm pretty sure this code is correct.(though it might be a bit sloppy to all you pros) Code:
Drop Down List With Months
I am trying to create a drop down list that has December 2006 as the first option and then goes up month and years till the current month and year (September 2007).
Putting List Into Drop Down
I am working on a directory of businesses which has 8 main categories and each category has several sub-categories. Example: Dining is a Category with Pizza, Fast Food, Chinese, etc. I have the sub-categories brought up in just a list on the left side of the page and when the user clicks on a sub-category it takes them from client_list.php to client_filter.php only showing businesses in that sub-category of the main category. So only pizza places listed under dining. However, I want to change the list to a (form) select box and then have the user click on the sub-category they want and then it takes them to the client_filter.php page to list only those bussinesses in that sub-categorie. So after that long explanation how do I change my code to do that. Here is my current code:
Insert From An Drop-down List
i have a table in wich i've inserted city's name.then i have an registration form in wich i want to display an dropdown list with the cities from the table, and if one city is selected to be automaticly added in the second table. how can i do that?
Custom Drop Down List
I am trying to get categories from the database and show them in a drop down list showing root category then their sub category underneath. Code:
Folder List Drop-Down
I am developing a PHP/MySQL project and as part of my initial setup and configuration scripts, the users can select a skin for the application, and a variable value ($skin) is updated to set the current skin, this works ok on it's own, but currently the user must manually type the skin name in a free-text box. Ideally this needs to be a drop-down option box, and I would like this to be populated by listing the sub-folders within the '/skins' folder, so that it's always up to date. The folder structure looks like this: /skins /skins/skin1 /skins/skin2 /skins/skin3 How can I use PHP to generate a list of the current sub-directories in 'skins' and populate the drop-down list?
How Do You Pass A Value From A Drop Down List?
I am completely new to this. I don't understand how to receive a value from a drop down list <select> menu. I have read many tutorials and none of them explain the process of receiving the sent data.
Drop Down List Of Months
I am trying to create a drop down list with 12 months as the contents. I need to be able to determine what the latest month is and then put the 11 months before into it (in the correct order). For example, it is September 2007 obviously at the moment, so that will need to be the last and latest month in the list. The other 11 will be in reverse order going back to August 2006.
Dynamic Drop-down List In Array
Q. How do I create a dynamically-generated drop-down list for use in an array. I'm using PHP with a MySQL database (through phpMyAdmin) My database table is called com_courses, and I want to pull the distinct 'title' fields and have them appear as a drop down menu for the user to select in a form. Here is my array, with (at the moment) manually-entered 'titles' (which I now need to be dynamically generated from my database field: 'com_courses.title' array ( "coursetitle", "Course Title:", $EXTRA_SELECTLIST, array ("Report Writing", "Recruitment & Selection", "Presentation Skills", "Essential Telephone Skills", "Time Managememt", "Customer Care", "Other"), 0 ), I am not an experienced programmer, but can play around with php to customize programs. I've read up on arrays (I bought a "Programming with PHP and MySQL" book, but it just stops short of this problem). I can't figure this one out.
Automatically Drop Down A List Of Phrases
I would like to know why when I go to a site like altavista.com and start to type in a phrase to search on does it automatically drop down a list of phrases that I have previously searched on, and how do I get rid of these from showing when I go to search. I removed all of my cookies that were stored in my temporary internet folder. Is there somewhere else I should be looking. I am using IE 5.0 on a windows 98 machine.
How Do You Insert A Value From Drop Down List To SQL Table?
I am a bit new to PHP and SQL so this may seem like a dumb question. I have already created a drop down list as part of a form which is automatically populated with values taken from a separate database. When a user goes onto this page and either leaves the default value or selects a value from the drop down list and presses the submit button, I would like that selected value to be stored into a database which I have already created in SQL. Just to let you know that I can do the above using a text field but just don't know how to do it with drop down list. If your going to explain any coding then it may help if I give you the names of certain items that are involved. Database is called "Company" Field within database is called "Name"
Load Runner, Drop Down List
Can anyone send me the script for supplying the values in drop down list of the web page? I have couple of drop down list controls in my web page. I need to supply multiple values for each dropdown list in my script. How can i do that? can you send me the script for this?
PLEASE HELP - Drop Down List Related Question
I am creating a dynamic dropdown list using a code snippet(Section A) as below: Section A: $sql_query=mysql_query("SELECT DISTINCT semester, year from schoolproject_pics ORDER BY year DESC"); echo "<select name="semester" onchange="GoTo()">"; echo "<option value="$semester">-Semester Year-</option>"; while($data = mysql_fetch_array($sql_query)){ if($data[semester]==@$semester && $data[year]==@$year){ echo "<option value selected="$data[semester]">$data[semester]:$data[year]</option><BR>"; } echo "<option value="$data[semester]">$data[semester]:$data[year]</option>"; } echo "</select>"; mysql_free_result($sql_query); The 'GoTo()' Javascript re-draws the same page with the chosen values of 'semester' and 'year' so that the values can be recovered by $_HTTP_GET_VARS, stored in two hidden variables and then used in another query to create another dynamic drop-down list, as in code snippet (Section B). $semesternow=$HTTP_GET_VARS['semester']; $yearnow=$HTTP_GET_VARS['year']; if((isset($semesternow) and strlen($semesternow) 0) and (isset($yearnow) and strlen($yearnow) 0)){ print("<input type="hidden" ID="semesterchosen" value="$semesternow">"); print("<input type="hidden" ID="yearchosen" value="$yearnow">"); $sql_query2=mysql_query("SELECT DISTINCT school from schoolproject_pics WHERE semester='$semesternow' AND year='$yearnow'"); echo "<select name="school" onchange="GoMore()">"; echo "<option value="$school">-- School --</option>"; while(list($school) = mysql_fetch_array($sql_query2)){ echo "<option value="$school">$school</option>"; } echo "</select>"; mysql_free_result($sql_query2); Now the question: When the page is re-drawn, how can the values of semester and year previously chosen, be displayed in the first drop down list. I tried to do it using the following, but it does not do anything: f($data[semester]==@$semester && $data[year]==@$year){ echo "<option value selected="$data[semester]">$data[semester]:$data[year]</option><BR>"; }
How To Display .txt Info Into Drop Down List
list out all the items from a file (data.txt) into drop down box for user to select. Eg. inside (data.txt) has Apple Orange Strawberry etc... How do I create a drop down list that can call out everything from data.txt (until end of file)??
Data Not Posting To My Database Php/mysql
I am having a problem postion data from my form into my database. My users visit my site and fill out a form which is suppose to go into my mysql. I check phpMyAdmin to see if the data got there but nothing. Below is my Code. could someone help me out. Code:
Mailing Data From Mysql Database
I have searched, but didnt find what I need. I am trying to mail someone if a user changes data in my MySQL database, which is being written to by a php script. All is set up, just need to be notified of what data got changed.
Writing Data To MySQL Database Using PHP
Can anyone tell me why the following code isn't working? $dbh = mysql_connect($host,$user,$pass) or die("Couldn't connect..."); $selected = mysql_select_db($db,$dbh); $name = $_GET['name']; $state = $_GET['state']; $desc = $_GET['desc']; $lat = $_GET['lat']; $lng = $_GET['lng']; $result = mysql_query("INSERT INTO re_cities (name, state, description, lat, lng) VALUES ('$name','$state','$desc','$lat','$lng')"); The script doesn't die when I attempt to connect so I'm assuming that isn't the problem. I'm pretty sure I also get a result because the following code echoes "City Add Successful". if ($result) { echo "City Add Successful"; } else { echo "City Add Unsuccessful"; } However, the data doesn't show up in the database.
Check Mysql Database For Data
Need to check if some info matches from mysql database in two tables to see if the current session user is on a friends list for the profile page he or she is viewing. If they do not exist in field, return an error. Here is the structure and what i got so far: Code:
|