Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database:
$connection=mysql_connec ("localhost", "f2821842", "f2821842");
$result=mysql_select_db("QUERIES");
$query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'");
while($row=mysql_fetch_array($query))
{$empname=$row['emp_name'];}
<form name="webregform" action="webadmin2.php" method="post">
<input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>">
</form>
When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?
View Complete Forum Thread with Replies
Related Forum Messages:
Populating Form From Database, Then Passing Results To Next Page
I have a multiple select input in a form that's being populated by a row from my database as such: <input type="checkbox" name="subm[]" value="$row[ID]"> That part is working fine as I can check the displayed page using View Source and see that the value is the correct row number from the database. It is then being submitted on a form by $_POST method to another page where I want to evaluate the checkboxes and display the contents of the entire row that corresponds to each value="$row[ID]" that have been checked. But I can't seem to get it to work. I'm having a problem passing the selected value. Can someone point me in the right direction? $query = ("SELECT * FROM `table`"); $result = mysql_query($query); print "<p>Data for Selections:"; print "<table border=2><tr><th>You chose:"; foreach ($_POST['subm'] as $value) { print "<tr><td>"; print "$row[ID]; "; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print "</td></tr>"; print "</table> "; } if (!isset($_POST['subm'])){ print "<p>No matching entry "; } mysql_close();
View Replies !
Filling Form With Database Info
I have a table with 5 fields for a tour business activity list : (1) id -table key (2) name (3)description (4)picture -text link not binary(5) country. I would like to create a form that takes all the activitys an puts it neatly down on site in checkboxes so user can select activtys.this will be linked to form mail.i would like the activitys to be seperated by the country they r in?
View Replies !
Validating Form Info Before Inserting It Into Database
I have been trying to create a PHP application where you can add customer contacts to a MySQL database. Now, my problem began when I created a form where the user can add in a customer's name and info to the database. In an effort to alert the user that they may be adding a customer that is already setup in the database, knowing that some of the customers may have the same names, e.g. there is more than one Bobby Ray Brown, I decided to add a script that queries the "customers" table in the database and searches for all results that match the input from the user. Code:
View Replies !
Creating A Form That Will Stick It's Info Into A Database.
I am creating a form that will stick it's info into a database. the info is basic (first name, last name, address There are a few fields that would be similar to multiple choice. but your basic form. Which would be better for organizing the database. have a table where everything is stored in ID, Name Value so that it would be something like 1,firstname, John; 1,lastname,Doe. or where an ID number is unique and all the user data is stored in one row. ID,firstname, lastname, city,state.etc.
View Replies !
Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it. The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like: Green Red Blue Green Black How can I make it so that Green only shows up once?
View Replies !
Populating A Dropdown From A Database
I have put together a script that populates a dropdown menu from a database. My database contains a table called casinocredit, and it contains records that have been enterend over 2 different months (may and june). There is a field in the database that contains the date in this format: 2006-05-12 00:00:00 So The drop down is currently showing a month for each of those records. I was hoping that it would only display one. (the plan is when a user selects a month (say May) and hits submit, then I would display all of Mays records on a different page) See the image i have attached for a view of what is happening. Code:
View Replies !
Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.
View Replies !
Re-populating A Form If Errors
I am learning php. I have created a simple Web page with a form. After receing the POST request, I do some error checking. In case of errors, I would like to re-post the page, but with the current values for each field. I have organized my files like this: 1) Webpage with the form (all in html, form action points to a php file) 2) php file that receives the request.
View Replies !
Populating Form Text Box.
I have a PHP form for entering data on-line into a mySQL table.. Because of the intended search facility, I require one field in the form to be completed with exact and precise item names and spelling. In testing, I had achieved this with look-up tables. Ideally I would like the selected item from one of five drop-down lists to autopopulate the form text field when selected. Alternatively at least the option of copy and paste. Copy and paste - for some reason will not work. Autofill worked fine on a test form with no database connection and in standard HTML and javascript, however, once the PHP is added to the page neither method works. Could anyone please point me in the direction of how to get the autofill to work?
View Replies !
Populating Form Fields
I have a online order form that does not require a user to be logged in to use, but if the user is logged in I am attempting to get certain fields to populate with information stored in the database for the user. If the user is not logged in I need the information to be sent to the database.
View Replies !
Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' "; $qry = mysql_query($sql) or die("Query not valid: " . mysql_error()); $res = mysql_fetch_object($qry); // This returns a row with a field 'Type' containing 'enum(...)' $res->Type = str_replace('enum('', '', $res->Type); $res->Type = str_replace('')', '', $res->Type); //now the string is something like this: one','two','three $temp = explode('','',$res->Type); //temp is an array with as much elements as the enum while ($temp) print array_pop($temp); This way is much more easier using the elements since they are elements of an array. Cleaver isn't it?
View Replies !
Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:
View Replies !
Auto Populating Form Fields
I know this isn't a PHP thing. But, I've been unsuccessfully looking for how to populate form fields with data found in other fields. For example, I would like to populate shipping information with the billing information - if they are the same. This would save the time from entering the same address twice. Does anyone know of a javascript site that is decent at these options?
View Replies !
Conditionally Populating Form Menus
I wondered if I could ask another question: I have a form which will allow me to populate a garments table within my database. Among the elements in the form, there is a suppliers drop down menu and a categories multiple select menu. I used the following code to populate these menus. Code:
View Replies !
PHP Not Populating Form Variables Passed Through POST Or GET
I"m running: Windows Xp SP2 Apache2 PHP5 MySQL4 Everything seems fine and dandy, and I can do scripting on server side, but for some reason I cannot get data from a form to be put into a variable. I have a simple form in an html page which submits, and in the php script that handles the input, none of the data in the form is going into the variables. My php.ini file does have all the GPC's in place(ie variable_order, the way they get processed).
View Replies !
Populating An Html Form With Mysql Data.
What I have is a basic html form I have made consisting of header fields and fileds that will be populated from a mysql database. The brackets are the actual db fields and denote where I want the data to populate. Here is a small example of the form. Code:
View Replies !
Populating SELECT Multiple Form Field And Inserting Into Db
I have an update form where I'm trying to populate a SELECT multiple field with a list of 48 categories, from tbl work_cat. And show, as SELECTED, the one or many choices that the user had previously selected from the 48 categories which are stored in tbl cat_relations as $relation_cat. Then allow the user to update their selections and update the database. But I can't get my form to work. First problem, I can't get the SELECT field on the form to show the categories, and then I don't know where to go from there. Below are my form page and my processing page. Code:
View Replies !
Reload Form Element Without Loosing Form Info
I have a upload image page which a user can upload image and some description to go with it. My need is the user would like to be able to create a folder before uploading his image but during have filled the form. The problem is that the list box which list folders will need to reloaded with out loosing all the data filler in the from ?!??!?
View Replies !
Info From My Database
So now basically I have this script that gets info from my database. You can see the page here and you can view the code here. Now here's what I want to do: I want the edit button and delete button to work How would I get php to load a new page, when I click the edit button, with in that page all the info of that row of the db in there?
View Replies !
Recall Database Info
Hi, I want to create a page where users can put in certain information like you normialy would in a form but when they click submit another page will load that will look like the original form the signed up with and everything they filed in that time will be there and they can make changes to that and then click submit and the changes are made to databse automaticialy.
View Replies !
How To Send Info To Database
im wondering how to submit info into a database. i know the code goes something lie $sql = "UPDATE <tablename> set $var = "var" but i know that is wrong and i want to put it in form so on submit it posts it in the database.
View Replies !
Info Deleted Itself From Database?
I got some info (news system) in a SQL database but after some days it deletes by itself it happened to me once but i thought i didnt remembered that i deleted it but today it happened again...it deleted by itself! lol I have other tables in the same database so its a table problem... How can i fix this? Did i miss something at the table configuration?
View Replies !
Get And Insert Info Into Database
I have one table (form) that has multiple fields. Here are few fields we need to know: ID, NAME, CITY, STATE, PROFESSION, x, y, z (x, y, z means more than 50 fields that give me more information about each name). The ID and NAME are unique and they don't change (each name has it's own ID). A NAME and its ID can be in any CITY, STATE or PROFESSION but this is fixed. That means if ID# 123 for Mr JOHN is Austin, TX, that will stay in Austin, TX for ever. I have more than 5000 NAME and it's ID, 9 professions, all US States and all Cities in my database. Here is what I need to do: I want to have a form on my site that my visitor finds his name first and then enters more information about him/her that will complete my database fields of x,y,z. What I'm thinking to do is to create a drop down list that the visitor first selects the profession. Based on the profession the second list shows the states that has that profession. Then by selecting the state, all the available cities will show up in the third list, and by selecting the city all the names related to that profession in that city, state will show up and he can select the name from the forth list. Then he enters other required information about him that will be send and saved in the database. Here is what I have done and I know to do so far: I have created the database with all the information in one table. I also know how to send data to database to be saved. But my problem at this point is how to create this list selection that narrows the search to find the right person.
View Replies !
Retrieving Info From A Database
I would like the code below to fetch and display in an html table the Ad_Id, Date, and Type_Job fields from the 1st 10 rows of a table called employment. I'd like the results to be sorted first by date and then by the Ad_Id #. I have replaced my username and password with "user" and "password". Currently, the script returns the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Also, the script is ignoring the css info that I have supplied. Code:
View Replies !
Inserting Info Into Database
I am trying to realize a function that after a user logged in, he/she can send comments. Hence, I am trying to get the session()'s user_id information, and insert it into the database. But somehow, the user_id could not be retrieved. Code:
View Replies !
Server/Database Info
I've been ever-so-slowly working my way through a book on PHP and I've started using databases. When I began, I installed Apache and MySQL on my Win XP computer to access my files without having to upload them. Unfortunately, I've forgotten my login, password, and database names - I can't connect to my DB or see if my code runs without them! Anyone know where/how to look for this information on my computer? I've had no luck so far digging through the files.
View Replies !
Ordering Info Returned From Database
I have a PHP page on my site which pulls back info from my MySQL database and displays it in a table under appropriate headings. Is there code that I could add to these headings so that a) the same page could be redisplayed with the information sorted by the third column instead of the first b) information in the columns could be displayed in reverse order (maybe Z to A or highest figure to lowest figure)
View Replies !
Session Variable Info To Database
I have a 2 page form. The first page page of the form POSTS to the 2nd page which, after being filled out, should send all the information (from pages 1 and 2) to the database. I have created a session variable and have placed it at the top of the 2nd page. For brevity´s sake I have placed only one of the variables in this example: <?php session_start(); $_SESSION["sessanimals"] = $_POST["animals"]; ?> After filling out the remaining variables on page 2, I want all the information (the info from page 1 brought over in the session variable and the info from page 2) sent to the database. I tried creating an INSERT RECORD on page 2 but only the variables on page 2 are subsequently sent upon submission. How do I get all the info into my database?? Here are a list of my questions: 1. Is there any way of creating one session variable for all my page 1 form variables (I have 20+ variables)? 2. is there a way to denote ALL the variables in = $_POST[]; or do they have to be listed separately? 3. How do I post all the data from page 1 and 2 into my database at once?
View Replies !
Update Database Info Using Forms
i have a page uses select and cases. i already have setup and working, auth/login to the page, create a new row in the table. i am now trying to have the user alter the information that the just put into the table. this is the code where i have setup to modify the info, $id is passed over. this puts the correct information into the form field. when i hit submit, the information, $name, $content, $id are not passed over. echo-ing results blank. PHP Code:
View Replies !
Hiding Database Connection Info
In a php script, I have to connect to a remote mysql database. I'm a bit worried that some user might be bale to retrieve the source of the page and see the user name and password to connect to the db. Is this resonable? What's the best way to avoid it?
View Replies !
Obtaining Info From Database Table
How do you obtain fields from a table and assign each field to a variable to be used as needed. An example: Say i had: table name : user Field 1 : User name Field 2: Password then i wanted: $username = field 1 $password = field 2.
View Replies !
How To Obscure Database Info In PHP Pages
I'm moving from Cold Fusion to PHP and I have a question that none of the books I have answers adequately: In Cold Fusion, database connection parameters like the table, username and password are configured on the server. Since they are at the backend, nothing is exposed on the page except the queries themselves. In PHP, from what I see, the database info is on the page. Is this not a security risk? How can one be sure that this info is not on the page sent to the user?
View Replies !
Displaying Daily Info From Database.
I run a site specifically about a theme park, and am looking for a simple script to display current info on the main page out of a database. It would look something like this... Today's Park Information Operating Hours: (Hours Here) Regular Live Shows: (Show/Time) (Show/Time) etc Special Events/Concerts: (Event/Time) etc Problem is I'm a complete newb, all I know of PHP is how to use include to put my navigation bar and such onto a page, and to do extremly simple adjustments to forum interface scripts, etc...
View Replies !
Sending Mail With Info From Database
Can anyone explain the best way to retireive info from mysql and then send it in an email? I'm completely lost on this. I can run a query of the database just fine, and I know how to use the mail function. The problem is I cannot figure out how to use them together. Anyone?
View Replies !
Simple Database Info Retrieval
I am trying to simply pull some code from my database and I keep getting either empty responses or an error saying that "$TableName" does not exist if I try to use that instead of the actual "company_profile" name in the query. The name of the page is test.php & am linking to it with a text link that links to "test.php?id=1". The id being one is obviously my first record in the database. Anybody have any idea what I am doing. I am just learning PHP, so I can't see anything wrong with it. All the database information is correct: <?php $Host = "localhost"; $User = "getitdon_warzol"; $Password = "jemy45"; $DBName = "getitdon_testing"; $TableName = "company_profile"; $link = mysql_connect ($Host, $User, $Password); $query = 'SELECT * FROM company_profile WHERE id="'.$_GET['id'].'"' $result = mysql_db_query ($DBName, $query, $link) or die(mysql_error()); {print ("Hello $result[name]</br>"); print ("Your email is $result[email]</br>"); } mysql_close ($link);?>
View Replies !
Obtaining Specific Info From A Database
i have a products table that contains all the products i will have on my website however for the configurator i want to select only the items, accessories extras that i want to selected the computer. i don't want to send out a SELECT query for each item...is there a way to send out one query that will fetch all the items i need? I thought it would be good to have an array of product id's and the have a query which would grab the info i require based on these id's Code:
View Replies !
Php Form Info...
have a form, with a text input "fieldname". method POST $var = $_POST["fieldname"] $var is then used to search in mysql select * from table where jobtype like '$var%' OR jobtype like '%$var%' OR jobtype like '%$var' OR jobtype like '$var' order by date asc; basically i'm doing a search for any string that matches the searched input, being at the beginning, middle or end of the jobtype column. query works great, except when the string contains the 4-letter word 'info' such as information or informative then the mysql query breaks down and give the usual: Error performing query: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY date ASC' at line 1 Now after much debugging, i found out that the php _POST variable treats anything with info as a numner of 0 value. inf is treated as text, nformation is treated as text, but anything with info gets a 0 value. Searched php.net and couldn't find anything related to this feature, looked under security to see if it was related to that, but nothing.
View Replies !
Entering/checking Info Into Mysql Database
I have set up a client database where one can view, add, edit and delete entries. I ran into a problem setting up the add page. On this page i have set up forms to add info into the DB, and it works fine, but i dont want duplicate clients. Is there a way to set it up so that when you submit the form with the info it checks for duplicates and if there is one returns "sorry this record exists?"
View Replies !
Retrieve An Image In Folder From Info Out Of Database
i am having problems displaying an image once i have uploaded it. i upload it to a folder and store its name in a database. below is the code to display the image. I have figured out the the code is not grabbing the name from the database but i can not figure out why. can anyone help? //Retrieves data from MySQL $data = mysql_query("SELECT IMAGE_NAME FROM item") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.abcxyz.com/pics/".$info['photo'] ."<br>"; }
View Replies !
Sends SMTP Mail From Database Info
I've got this script that I want to use to send SMTP mail from a form that allows the user to select recipients from a dropdown list that is created using database info and send a message. Two of the selections in the dropdown list are groups. My script works fine when the user selects only one recipient. I run into trouble when the user selects one of the two groups. The message ends up getting sent numerous times to the people in the group. I received the message 9 times. I think the script is looping more times than it should. Does this make sense so far? Here's the script that receives the form data and connects to the DB to get the recipient email addresses and then sends the message: Code:
View Replies !
Retrieving Database Info Based On User
I'm still quite new to php and mysql but I have been unable to figure this out. I'm attempting to display a specific row and column from a mysql database based on the user. $result = mysql_query("SELECT fbleague FROM users WHERE username = $_SESSION[username]"); fbleague is the column users is the table username is the primary key column $_SESSION[username] is the username variable Then later I try to display it with echo "You are in league $result "; I know $_SESSION[username] is set correctly because I can display that with no problems.
View Replies !
File On Server - Store Info In Database
I have a html form that allows a user to upload a file to the server. For each file that is uploaded, how do I store relevant information such as date uploaded, name, etc. in a database table? Here's my code so far: $query = "INSERT INTO tbl values('".$fileName."', NOW())"; $result = mysql_query($query) or die(mysql_error()); And how will I get the info in the database to link to its relevant file on the server? Basically, how can I select and display a file based on the database data?
View Replies !
Populating Form In Parent Window With Value From Popup Window
I have a text box in the parent window.. now i want to populate this text box with a user_id that i will get from query within a popup window.. How do i get the value from the popup window to be passed to the main window form field in php. I know how it can be done in javascript but when i tried combining javascript and php i dont get the desired result.
View Replies !
Getting Info Out Of Dynamic Form
I am using the following code to produce a dynamic form. $result = mysql_query("SELECT id,weight,date FROM weekly_data WHERE weight IS NULL AND subscr_id = '$toss' AND date <= now()"); if (!$result) { die('Invalid query: ' . mysql_error()); } print"<table width=ď`%' id='catchup' border=Ɔ' cellspacing=Ɔ' cellpadding=Ɔ'>"; print "<form name='form1' id='form1' method='post' action='catchupprocess.php'>"; print"<tr>"; print"<td></td>"; print"<td>Weight</td>"; print"<td>Date</td>"; print"<td>Waist</td>"; print"<td>Measure</td>"; print"<td></td>"; print"</tr>"; while ($row = mysql_fetch_array ($result)){ //echo $result; print"<tr>"; print"<td>"; print"<input name='".$row['id']."' size=Ɗ' type='text' value='".$row['id']."'/>"; print"</td><td>"; print"<input type='text' size=ƌ' name='weight".$row['id']."' value=''/>"; print"</td><td>"; print"<input type='text' size=ཆ' value='".$row['date']."'/>"; print"</td><td>"; print"<input type='text' size=Ɖ' name='waist".$row['id']."' value=''/>"; print"</td><td>"; print"<input type='text' size=ƌ' value='$measure'/>"; print"</td><td>"; print"<input type='hidden' size=ཆ' value=''/>"; print"</td>"; print"</tr>"; } print"<tr>"; print"<td> </td>"; print"<td><input name='Reset' type='reset' value='Reset'></td>"; print"<td> </td>"; print"<td><input name='submitcatchup' type='submit' value='Submit'></td>"; print"<td> </td>"; print"</tr>"; print"</form>"; print"</table>"; ?>
View Replies !
|