Dynamic List Populated By MySQL Table
I am building my first php page and I've ran into problems trying to create a dynamic drop down list for an INSERT page. My page is based on this example from mysql.com.
I want to populate the list from a table in MySQL, but when I test the page the list only contains the first record. If anyone can help me out, or recommend an easy way to create dynamic menus/lists, I will be very grateful.
This code appears above the FORM ACTION:
$NearMajorCity = mysql_query("SELECT NearMajorCity_ID, NearMajorCity FROM NearMajorCity");
This code is within the FORM:
<SELECT NAME="NearMajorCity" SIZE=1>
<OPTION SELECTED VALUE="">Select One
<OPTION VALUE="">---------
<?php
while ($NearMajorCity = mysql_fetch_array($NearMajorCity)) {
$NearMajorCity_ID = $NearMajorCity["NearMajorCity_ID"];
$NearMajorCity = $NearMajorCity["NearMajorCity"];
echo("<OPTION VALUE='$NearMajorCity_ID'>$NearMajorCity
");
}
?>
</SELECT>
I want to be able to view the names of the Major Cities in the list, but I want the NearMajorCity_ID inserted into the table.
View Complete Forum Thread with Replies
Related Forum Messages:
Dynamic List From Sql Table
I would like to put a dymanic select list on a form with the choices coming from a row of a table, table has the structure id colour1 colour2 colour3 and I would like to give the dropdown the colour associated with the entry for each of colour 1-3 so if a line has id=sss colour1=red colour2=black colour3=NULL I would like the dynamic dropdown to have 2 choices, red or black but if the next row had colour1=red colour2=black colour3=green it picks up those values instead. The info for each id will be different, I have a table being built populated from the same table at the moment but built from different columns so I have a suitable record set already.
View Replies !
Dropdown List - Trying To Get Default Populated From Db.
Nooby question but when I try and get this to work (it should identify which rows in the database have GK, MID, DEF, FWD against them and then put SELECTED into the option value to give a default of what the entry is currently) it just adds SELECTED to all the results as if $row["Position"] is returning true against all four conditions? What am I doing wrong? CODE:..
View Replies !
Dynamically Populated List Menu
I have a DB with a field called county in a table called info. I want to populate the list menu below with the counties in the field county. Would there be a way to get around the fact that there will be many entries with the same county and we want only 1 instance in the list menu? Code:
View Replies !
Adding Columns To A Populated Table - Bad Practice?
I got a scenario where i need to design a table for userProfiles. Currently the profile stores userID's (foreign key - there's a user table which stores the userIDs), and against each userID i need to store the number of times the user has accessed each of the available services offered. Code:
View Replies !
Mysql Ajax Dynamic List To Fill More Than 1 Textbox With A Dif.value For Each?
Ok, I have a database: ie... Id | cab | price | w1 1 | wall | $300 | $19 on my form I have three textboxes: input1 is cab with autocomplete, input2 is price, & input3 is w1 The way I have it now works great, I type a few letters in input1, it pulls up a list, once cab is selected it populates input1 with cab and input2 with price. I want to know once cab is selected, if it can populate input2 with price & input3 with w1 as well? Code:
View Replies !
Dynamic Checkboxes From Mysql Table
tearing my hair out over this! I have 2 tables: PTable which lists all traits pid,ptype 1,good 2,bad 3,neutral UserP Table which records user and traits uid,pid 1,2 1,3 9,1 9,2 9,3 For a certain user UID, how can I get php to automatically create html checkboxes listing ALL traits from PTable and check each trait based on the UserP table on a webpage? Hence, if UID is 1 it should show good - unchecked bad - checked neutral - checked
View Replies !
Mysql Question Dynamic Table
I have a news page which pulls the news articles from mysql like this PHP Code: "SELECT * FROM tbl_news WHERE pressid = $_GET['pressid'];" This code pulls all the news for the particular pressid, now what I would like to do is some how have the tbl_news be dynamic, I have another table in mysql called tbl_articles, and depending on which link the user presses depends on the sql query, i surpose i need an if statement, PHP Code: if $_GET['pressid'] == 1 OR 2 OR 3 OR 4; { "SELECT * FROM tbl_news WHERE pressid = $_GET['pressid'];" } else { "SELECT * FROM tbl_articles WHERE artid = $_GET['artid'];" } Will this work ? and is there any better soultions.
View Replies !
Delete Textfile List From MySQL Table
I have a list of email addresses that I need to delete from my database and they are in a textfile, one on each line like below... a@b.com c@d.com e@f.com etc. does anybody have a snippet of PHP code that I could use to accomplish such a task?
View Replies !
List Box - Automatically Load From A Mysql Table
i have a form with a drop down menu on it where the user can select a team from a list. how do i get this list to be automatically on page load from a mysql table called teams on the page load? I have tried several things before but i always seem to get the php code just appearing on the page rather than going off and processing the code. and i have used the <?php ?> tags.
View Replies !
Get List Of Messages From One Table, Message List Indicator From
I have two tables. One has a list of messages left by users using fields named mbxno for the mailbox and msgno for the message number. I have another table that has mailbox settings for each user that contains a field named "messagelist" to indicate if they want to be included on the message list or not. What I'm trying to create is a list of the most-recent messages with a lookup on the users table to indicate whether a message in the list should be included in the message list based on the user's mailbox settings. SELECT messages.msgno, messages.mbxno, users.messagelist FROM messages, users WHERE (users.messagelist = Ƈ') ORDER BY msgno DESC LIMIT 100 What I'm getting, though is a list that looks like this: mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 1114 msgno: 0412141623 msglist: 1 I think what's happening is that I'm using the wrong type of join and more rows are being created than necessary. If I add "DISTINCT" to the query, I get a list of the most-recent messages as I expect, but the "messsagelist" value is sometimes wrong (again, probably because the data is getting jumbled). For example, the messagelist value for the second row (2214) should be 0, not 1. mbxno: 1114 msgno: 0412141623 msglist: 1 mbxno: 2214 msgno: 0412141622 msglist: 1 mbxno: 2189 msgno: 0412141408 msglist: 1 mbxno: 0000 msgno: 0412141213 msglist: 1 mbxno: 0003 msgno: 0412141213 msglist: 1 mbxno: 2265 msgno: 0412132029 msglist: 1 mbxno: 0000 msgno: 0412131950 msglist: 1 How should I be doing this? If nothing else, what kind of join will work with a long list compared to a value from a short list?
View Replies !
Dynamic List Box
ok, im trying to make a select box (list box) so that its size is dynamic (depending on the amount or records of a given field (medivas), so I can make multiple selections from it. Code:
View Replies !
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?
View Replies !
Dynamic Mailing List?
I have a schedule of people that need reminders sent to them weekly. I have figured out how to set a Crontab to send the reminder automatically ... but the people are not the same every week. I know that I could build multiple scripts and hard code the email addresses, setting a cron job for each - but is there any way to build ONE script that will read a text file based on the date and pull the names/email addresses off of that?
View Replies !
Dynamic List Order
I was trying to get the list box to display the id numbers in ascending order however the code below does not work, just wondering how to fix it? <?php $g="SELECT*FROMemORDERBYiDASC"; $q=mysql_query($g,$link_id)ordie(mysql_error()); if(mysql_num_rows($q)>0) { ?> <select name="d"> <?php while($r=mysql_fetch_assoc($q)) { ?> <option value="<?phpecho$r['Id'];?>"><?phpecho$r['Id'];?></option> <?php } } ?>
View Replies !
Generating A Dynamic List
I am tying to write a statement that will compare the values of 2 columns, and display the result in a temp table. ex. Table A has the following columns: "Minimum" and "Maximum." The temp table will hold the reult of the difference between the 2 columns of table A. Scope: I am trying to crate a drop down with the resulting data as it is incremented. If Min = 2 and Max = 7, the TEMP tab;e should get the results of 2,3,4,5,6,7. I want to have this result displayed in a drop-down list.
View Replies !
Dynamic Pick List
I have been developing programs in perl and oracle and have recently switched to php. I need to create a form that has four of five seperate pick list on it. Each item in each of the pick list depend on the users previous entry. For instence if the user picks Ford then Taurus, Ranger, Focus,.etc show up in the next pick list then the user picks Ranger and 2 wheel drive, 4 wheel drive, etc show in the next pick list box on so on. I know how to this if the screen is refresed after each user entry. What I would like to fugure out how to make the screen automatically update each pick list and not refreshing the whole screen.
View Replies !
Dynamic Drop Down Box List - Php
I have two dropdown boxes. Two boxes have values from two different tables. They dont have any common field to relate with. I would like to display the values based on selecting the first combo box value. If i select first combo box value, then automaticlly the second drop down box value should be changed. Code: ....
View Replies !
Sub Headings In A Dynamic List
I wonder if someone can help me with a problem I am having whilst displaying some external links that are being taken from a MySql database. The code below may not be the best writen but it does work. I have a database of categories (See SQL below) that are highlighted in blue with yellow text. The contents (See SQL below) of each category are listed below each blue header using alternate green and yellow rows using a type number for each category. Code:
View Replies !
Dynamic Select List
I am wanting a dynamic select list which is populated from my DB. My query is: $query = "SELECT pk, type FROM un_styles"; I want to display the type in the select list, then use the selected type. So what i am basically asking is could someone show me the code to do this please.
View Replies !
Dynamic List Content
i'm making a hierarchical Order list for this i've created database where parameter_cd,parameter_desc,upper_parameter_cd my page is like this Code:
View Replies !
Dynamic Form List
I'm trying to get a dropdown menu where the options are made up from entries in my database. Bellow is what I've tried but it only puts the first item in the list and the rest appear as normal text next to the dropdown box. Code:
View Replies !
Dynamic Drop Down List
I have poured over these and other forums, but can't find out what I'm doing wrong. I've found a few threads that deal with what I'm trying to do, but they didn't fix the problem. What I'm trying to do is populate a drop down list based on info in my mysql database table. I have a game number id (game_ID) I want to use as the 'value', and the game name (game_name_long) that I want to use as the actual entry in the list box. Here is the code I am using that takes the data from the db and populates the drop down list box: Code:
View Replies !
Dynamic List Items
I’m trying to build a multi-level unordered list from a database query. I can't figure out a good way to do this. How can I create this: Code:
View Replies !
Dynamic List Population
Code: <form action=""> <select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat">Fiat</option> <option value="audi">Audi</option> </select>
View Replies !
Dynamic List Items Repeating Themselves
I'm working on this online magazine, and each page (well, other than the front page) has a menu included on the right-hand side consisting of articles divided into three sections: articles, columns, reviews. For some reason, whenever I click on one of these article links, that link takes the place of the first link in the section. You can see what I mean here: PHP for the included right_menu.php PHP Code:
View Replies !
Dynamic Checkbox List - DB Update
I have a set of questions which are being dynamically output: for($i=0; $i<count($question_array); $i++) {echo $question_array[$i][question] . "<input type='checkbox' name='question_" . $question_array[$i][id] . "' value='Y'' . "><br>";} I then want to update each question in the DB. I want to loop through each question id and carry out the relevant action (either enable or disable). What is the best way to do this?? As I am dynamically generating the variable name (e.g. question_50) what is the best way to loop through these updating the relevant id?
View Replies !
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.
View Replies !
Dynamic Form Option List
I want to create a dynamic drop down option list in a form, but I just can't wrap my head around this. Both of the below scripts work as intended, but how do I make the mySql query results work with my existing script? Yes, I know I must replace the "$options = array" part in the top piece of code, but I need a little more guidance than that. Code:
View Replies !
Creating A Sort Of Dynamic List.
I'm wondering how I should go about creating a sort of dynamic list. I have a folder, let's just call it folder, which is filled with files called... file01.jpg file02.jpg and so on, there is also a folder in folder called folder1. These are all contained in localhost/site/. What I am wanting to do on a php page is list all the "files" inside folder, but not show folder1 in that list, and also for the files to be listed correctly, not like 1, 10, 11, ..., 2, 21, etc. Plus above some files there will be headings. (These are all links as well to a php page files.php?#) And finally I would like to know how to, instead of displaying the filename, which would usually happen, but instead just cutting off the word "file" and the ".jpg" after the number.
View Replies !
Searching Dynamic Driven List
I have a members database will all their personal details in. I have a page running a SQL query to display a complete list of all these people. This is what my query looks like: $sql_prop = "SELECT * FROM $db.members WHERE area = '".$_REQUEST['area']. "' ORDER BY name ASC; $result_prop = mysql_query($sql_prop) or die(error_report("Mysql Error", mysql_error()." $sql_prop", $_SERVER['REMOTE_ADDR'])); "Error Report" is just one of my functions. I have two forms fields on this page, "Name" and "Address". I want to be able to search the listing that this SQL query has returned for those fields, ie. the user enters "John" in the form field and it returns all entries within the query matching "John". The reason I'm using this: area = '".$_REQUEST['area']. "' in the WHERE clause, is just to ensure that the person viewing this list can only see members that are in his area. On the previous page there is a piece of code that gets the session "area" and brings it across to this page. I'm keen on keeping that code in. It works for me at the moment. Any ideas? How can I search this already filtered list?
View Replies !
Dynamic Form - How To Set Values Of A List
I have a form with a list/menu in it that is populated with records from a database. The items in list#2 are based upon what is selected in list#1. I have been able to use a combination of php and javascript to get it to work, but the javascript reloads the page to get list #2 to refresh - and that clears out any other fields that have been filled in. Instead of javascript being called for the 'onchange' event for list #1, I'd rather it call php when list#1 is changed and so reset the values in list#2. OPTIONS: 1. I thought I could have a php function that is called (i.e. onchange="<?php reload();?>" but I can't figure out how to set the values of the list from within the php function. How to reference form objects with php?
View Replies !
Dynamic List Has Multiple Entries
On an input form there is a dynamic drop down list to select from a dozen different categories. The form inserts correctly into the database. The problem is that every time a category is selected the drop down menu list it an additional time. For example if the list has: apples, pears, oranges. If pears is selected the drop down list will display: apples, pears, pears, oranges. Code:
View Replies !
Dynamic Search/list Thingy
I would imagine something like this: PHP Code: class request { public function getList($tbl, $cols = array('id'), $access_type = ACL::READ, $options = null) { // do option parsing, fetch data, return array } } ( $options = single array which holds 'order', 'ordering', 'min', 'max', 'limit', 'offset', 'search_text' & 'search_col' )
View Replies !
Member Area With Dynamic File List
I have an Apache 1.3.31 with PHP 4.4.1 available and want to create some kind of "member area" with a per-user or per-group listing of files that can be downloaded. How would I do this? At present I just protect the individual files using .htaccess and .htpasswd files and give out direct URLs to the files together with username/password. What I'd like is some login functionality where people can log in using their username/password and then find a list of files they can download together with additional information individually tailored for that user.
View Replies !
Dynamic Drop-down List With Array - Question
Can anyone out there give me a pointer regarding creating a dynamically-generated drop-down list connected to an array? And is that question as clear as chocolate spread? Here's what I've got. I'm using PHP and MySQL database. I'm customizing some calendar software, and I want the user to fill in a form by selecting a title from a drop-down list, generated by my MySQL database. However, the program I'm customizing uses arrays, which is where I'm stumped. What do I need to add to this code to make the array of titles(eg "report writing" etc) come from my database, rather than the manually-entered values that you can see here. The field I want to pull from is called 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 hope it's not cheeky to ask this, BTW I bought a book on Programming with PHP and MySQL, but it doesn't answer this question,
View Replies !
Print A Dynamic List Of Files To Seperate Divs
I have a database table of files which fall into different categories. Each category has a numerical value. I want to seperate the files into the correct <div> tags based on their category so I can then show and hide the <div> depending on which category is selected in a dropdown. It sounds easy enough but I can't seem to think right now and Im stuck. So I would a have a string for each category. To this string I add the file information for each file in that category...and then print the strings..
View Replies !
Dynamic Table Or CSS Only
The HTML forum is currently debating “do you use table or div”. Since it’s Friday! A question not really regarding a chunk of specific code comes to my mind <<< We both dynamically create rows, <tr> <td> etc… But have you encountered or written a script that build pages dynamically generated only using CSS >>>.
View Replies !
Dynamic Table
I have an SQL table I am looping thru and displaying the data in a dynamic table. My issue is it has an empty field the td does not display the table data border. if(!$row['Initial']) { Â Â Â Â Â Â Â echo "<td width=10> </td>"; Â Â Â Â Â Â Â } else { Â Â Â Â Â Â echo "<td width=10>".$row['Initial']."</td>"; Â Â Â Â Â Â } and when I check the source code, instead of a value of Code:
View Replies !
List All Table Fields
I'm looking for a script to list all fields in mysql database table, can someone show me a typical code or a link where I can get such info.
View Replies !
Dynamic Image Table
I have a problem that I believe is pretty simple to solve, but I have been beating my head against the wall. What I want to do is just display images from a mysql database into a dynamic table. For example, I want the images to fill up 5 cells on one row and then create a new row, and so forth until all the images are displayed. I have tried several diffent scripts but with now luck. The database fields are 'id', and 'image'. The 'image' field just has the image names (like example.jpg), and are linked to images in a folder like this:
View Replies !
Dynamic Data In Table
Trying to display dynamic data in a table. The code spits out the table just fine, but won't display the $name variable at all, I just get table cells w/ broken links. I must be missing something but can't get it, thanks. my code:
View Replies !
Dynamic Table Generation
I have a database, and I am using PHP to retrieve data from the database. Now I know I can format that data into a table easily using loops and everything, but I was wondering how I could stagger the colors of the table rows. That is, every other row is a darker or lighter color than the row above or below it, so that the user can easily discriminate between rows of separate, usually somewhat unrelated data.
View Replies !
Dynamic New Line In Table
I have a php script which pulls entries from a MySQL database, I want it to display all the enteries, but only 4 per row in the table, then it automaticaaly adds </TR><TR> and starts again.
View Replies !
|