Querying Mysql Database Based On Values From Html Form
I want to build a simple form for querying database having business organization info. The form has four fields name, category, city and state. Users should be able to search based on any of these fields. Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Querying A Database Using A User Form.
I am currently trying to build a mock PHP Website upon where a user can query for an insurance quote ([premium]) by using a form that interacts with a MysQL database. The fields for the database are [age] [grp] [region] and [premium] (premium being what I want to return to the user). Ok so I need a form, the form I have is as followed; <form action="capture_car_input.php" method = "post"> <P> Please fill in the form below with your details to generate your car insurance query; Code:
View Replies !
Php Code For Querying Mysql Database?
I came upon this thread while looking for code for a project I am completing for university. I have made a form with a drop down menu so that the user can query the database about which course is available in each month. However I keep getting this error message Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /Applications/xampp/xamppfiles/htdocs/paul/month_drop_down.php on line 41 The php code I actually got from this page: http://www.webmasterworld.com/forum88/4831.htm I have tried to adapt it to suit my purposes and it seems that all my database information is correct but for the likes of me I cannot work out why the php code is not processing the form data from the drop down menu. Would anyone here please be able to have a quick look at my code and see if there is anything that may be stopping it from functioning? There are two fields in my table which are called 'month' and 'course', the table itself is called months. Code:
View Replies !
Using A Php Html Form With Data Which Is Loaded From A Mysql Database.
I am using a php html form with data which is loaded from a mysql database. Three of the fields are textareas. The data loads into these fields fine, except that the loaded text starts at what appears to be 2 or 3 tab characters to the left. See illustration: +---------<this is a textarea object>---------+ | This is about the way that| |the text loads from the database field. | | | | | +---------------------------------------------+ It's almost as if there's a textarea "align" property which is set to "center" by default unless otherwise explicitly stated. Is there some setting in the wrap property that will fix this, or should I be looking elsewhere?
View Replies !
Use A Simple Form Into Html Verified Against A Mysql Database
I'm setting up an account login: should I use a simple form (user name and password) "embeded" into html verified against a mysql database or should I use the challenge/response scheme (also verified against a mysql database? Basically, is there any benefit to using challenge/response over merely submitting user name and password (like a search engine)?
View Replies !
Mysql Store Images On Database From Html Form Again.
i am trying to upload images to a database from an html form. This script is not connecting to the database and i do not know why. when i hit submit i get: This file has the following Database ID: 0 it acts like something happened but no information is goinig to the database. am i missing a binding or something? Code:
View Replies !
PHP:Unable To Post Variables From Html Form To Mysql Database
Plz dont treat this as another newbie query , i did my homework but still getting nowhere :( :( :( Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to post data from html form to php file(connecting to mysql database and inserting into a table) . This seemingly simple problem is making me go mad !!! I googled extensively and already tried the following I enabled " register_globals = On " .... in /etc/php.ini and also took used _$POST syntax. wot could be the problem .... is it the case that /etc/php.ini file is not being read .... how do i know whether this is the default location for php.ini? Where can i find the PHPRC environment variable (the variable responsible for the php.ini default location) Is the problem something else .....? Following is the code ... form.html --------- <HTML> <HEAD> <TITLE> email entry form </TITLE> </HEAD> <BODY> <P>plz fil the form </P> <FORM METHOD="POST" ACTON="form-handler.php"> NAME: <BR> <INPUT TYPE=TEXT NAME="givename" SIZE=25> <BR> AGE: <br> <INPUT TYPE=TEXT NAME="givenaddress" SIZE=25> <BR> <INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML> form-handler.php ----------------- <HTML> <HEAD> <TITLE> EMAIL FORM HANDLER </TITLE> </HEAD> <BODY> <? mysql_connect("localhost","root") or die("Failure on db connection"); mysql_select_db("mydb");
View Replies !
Php Based Html Feedback Form Produces Blank Emails
I have a php script to handle feedback on a website that I've built for a colleague. The site was based on a template that uses a flash header and 'iframes'. Unfortunately, when the visitor submits the form data, the email that is sent off does not collect any information from the form. I'll admit I'm quite new to php so this is foxing me. Extracts from the Contact page on the site are provided below plus the php file. Code:
View Replies !
Keep Values In HTML Form With PHP
I'm trying to process a form. In my data validation function i try and check for errors in the user submitted fields. In the fields in which are fine i want to be able to keep the values in the form when there are errors and clear the fields that have errors in them. For some reason i cannot get this to work. Here's my code, i've cut it down to the relevant parts. The first file is the index.php file which shows the form but first checks for errors. The second file has all the relevant php functions i call defined. In form.php i just show a small piece of the show form function where i try and present a text field with its default value. Code:
View Replies !
Values Form In JS/HTML
I have a JavaScript which is calculating some things based on exchange rate, In this script I use 2 values for EURO and USD which I get them from a form. Code:
View Replies !
How PHP $_POST Gets The Multiple Values From A HTML Form?
I am try test a simple HTML form with PHP <form method=POST action="testing.php"> Cat <input type="checkbox" name="pet" value="cat"> Dog <input type="checkbox" name="pet" value="dog"> Pig <input type="checkbox" name="pet" value="pig"> <br> <select name="dates" multiple> <option value="Monday">Monday</option> <option value="Tuesday">Tuesday</option> <option value="Wednesday">Wednesday</option> <option value="Thursday">Thursday</option> <option value="Friday">Friday</option> <option value="Saturday">Saturday</option> <option value="Sunday">Sunday</option> </select><br> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form> When I checked cat, pig and selected Tuesday and Saturday from the form and click submitt My testing.php is <?php $pet = $_POST['pet']; $dates = $_POST['dates']; print_r($pet); var_dump($dates); ?> The $_POST['pet'] and $_POST['dates'] are NOT return as array nor multiple strings seperated with a comma. It only return the LAST string I have checked and/or selected. How do I get the multiple values from the checkbox and the multiple select from a HTML form in PHP?
View Replies !
Dynamic Photo Gallery Based On Mysql Database
I would like to turn my attention to using PHP to organize hundreds of images on my site. I would appreciate some direction. I have in mind putting the image names in a database and will use those names to create links, likely output as a table or drop down menus in a form. I specifically wonder if there is any way to "dynamically" create thumbnails in PHP from the full image? Alternately, are there any programs out there for "batch creation" of thumbnails?
View Replies !
Database Querying
Heres my problem: Im currently working on a project whereby i am using 'open database connectivity' to display items on my webage from my MS Access database. The tutorial displayed on PHPFreaks has been a tremendous help however as a php beginner (still) im having problems querying my access database in the way that i want. What im trying to do: I have two tables (category.tbl and product.tbl) which both contain 'CategoryId' as the foriegn key. What i need is some PHP code to query the database in a way which displays a category and then a list of associated products, followed by another category and then that ones associated products. Code:
View Replies !
PHP/MySQL: Query Based On Selected Form Option
Using PHP and MySQL. Trying to put a list of categories into a drop down select option of a form like: <form name="form" action="<? print $_SERVER['PHP_SELF']?>" method="get"> <select name="subject"> <option value=""></option> <option value="field1">Field 1</option> <option value="field2">Field 2</option> </select> <input type="submit" name="Submit" /> </form> Then I want to process it so the MySQL query gets done depending on what was selected. I came up with this: //connect to database mysql_connect("$dbhost","$dbuser","$dbpass"); mysql_select_db("$dbase") or die("Unable to select database"); // Build SQL Query if (isset($_GET['subject'])) { switch($_GET['subject']) { case 'field1': $query = "select * from tips where category = 'field1'"; break; case 'field2': $query = "select * from tips where text like 'field2' "; break; default: echo 'No subject found' } } $results=mysql_query($query); $numrows=mysql_num_rows($results); etc etc etc But that switch doesn't seem to work. Anyone have a suggestion as to how I can code this to do the MySQL query based on the subject?
View Replies !
A Tool For Form Generation Based On A Mysql Table.
I'm looking for a tool that auto generates forms based on a mysql table. I need an interface that will allow: 1. picking a list of columns from the table (so a form that inputs only part of the table's columns is possible to generate). 2. picking a set of validation rules out of a predefined set of possible validators. An example usage of the tool will allow a webmaster to alter the details required for users sign up in two steps: 1. altering the mysql table adding some new columns. 2. picking which of the new columns should be requested in the signup form and how to validate each. After the second step the signup form will be automatically updated. Before starting to write such a tool I want to make sure that it doesn't already exist. Searching the web I found two similar projects: phpMyEdit(http:// www.phpmyedit.org/), and PHP Form Generator(http:// www.phpformgen.com). But both don't allow what I described above.
View Replies !
Having Trouble Querying My Database
I'm new to this and having a bit of trouble with the syntax. <?php // Query the Database $query = mysql_query("SELECT * FROM table_links"); while($row = mysql_fetch_array($query)) { echo "manufacturer". $row["manufacturer"] . "<br>"; } ?> At the moment I have two questions. (1) there is an error caused by the line that begins with "while" (2) I want to only list items with a specific value in a field called cat.
View Replies !
Double Quoted Values From Database Won't Show Up In Form
I enter user input from a form into a mysql database using addslashes. When I access values with a double quote from the database they won't show up in a text form field as the default value. I use stripslashes when accessing database values, magic_quotes_gpc is on, magic_quotes_runtime is off, magic_quotes_sybase is off.
View Replies !
HTML Form To Database
Is it easy to create an HTML form that connects to a database through a data handling form. I have php 4.4 on my server and wrote all my scripts in 5.0 language and they dont run so i just wanna use an HTML form to submit to a database and to retrieve info from it.
View Replies !
Increasing Certain Values In MySQL Database
Each post in my announcement section has an IndexNo . . . so far I've had to do enter that automatically. How do I rig something up so that php will extract the most recent (or last entered) news post's IndexNo and increase it? The IndexNo is stored as an integer so increasing it is no worry . . . my real problem is how do I tell mySQL to give me the most recently posted news article?
View Replies !
Insert Data To The Database From An HTML Form
i want to insert data to the database from an HTML form but when i run the script it will insert NULL to the database. On that note i like to request for help from anyone. This is my code <?php include "connect.php" $sql = "insert into TEST values(:name)"; // Parse SQL $stmt = OCIParse($conn,$sql); // Bind php variables to Oracle columns OCIBindByName($stmt,"NAME",$name); // Oracle converts all column names into UPPERCASE // Run SQL OCIExecute($stmt);
View Replies !
Form Code And Mysql Values
I am creating a form setup where people can tick checkboxes or option buttons to express a preference. What I want to do is have that value - either 0 or 1 stored as a db field, and then, when the client wants to print out their preferences have those binary values converted into a text value as part of the print out (bt not stored in the DB). For example, A user requests soup for a first course instead of cheese. That choice is stored in a db under the users login. when they want to rpint their menu, the system prints out Soup rather than the integer value. I know this would need each checkbox to be individually identified, but that's not problem. What I'd like to know is, is it possible?
View Replies !
Querying Mysql
I'm trying to filter information from my database, displaying results based on what a user selects. They choose the team on a previous page, and this is sent to this page via GET. The query involves COUNT, JOIN, GROUP BY and ORDER BY, and works fine until I add the WHERE part. The tries table has a column called teamID so I thought I would be able to simply add the WHERE part in and it would filter out only those records where the teamID matches the one selected by the user. Code:
View Replies !
Querying In Mysql Through Php
I have been trying for weeks now to create my own search engine, i am trying search for keywords in mysql through a query in php, the keywords are entered in an input box in html. Does anybody know the code or fancy having a bash at it???
View Replies !
Pre-selecting Options In Html-form According To Database Entry
I've got a html-form consisting - among other fields - of several drop-down-boxes and radio button groups. With this form you should be able to either create a new dataset or to edit an existing one. If the latter is the case, my application should propose values (the ones which are already in the database) and write them into the input-fields. My problem is, it should have the according options pre-selected and the checkboxes checked, and I've no idea how to do this. (Example: I've a dropdown box for languages, and my dataset says the language is English, then in my dropdown box the option "English" should be preselected when this dataset is to be edited).
View Replies !
Updating Multiple Form Values To MySQL
i am building a content management system for my employer's Web site, which is a daily newspaper. haven't had too much trouble learning PHP up to this point, but I have a problem now that I am finding difficult to figure out. any help would be much appreciated. I have two MySQL tables for a Poll on our site, one named PollQuestions and one named PollAnswers. I am trying to build an administration form that will allow the user to pull up both the question and answers for any given poll and edit them if they need to. I haven't had a problem with the Poll Question, but with the Poll Answers, I am unsure how I can pull each Poll Answer into a text field and update all of them in one query based on an ID field for the answers. In other words, I have each answer pulling into the form from the database and for each answer, i have a hidden field that stores that particular answer's ID number. So how do I update all of the answers in one query based on that particular answer's ID number? I have written the following code, but it does not work. Any help would be much appreciated. For the form itself, here is the code for the Answer text fields:
View Replies !
Updating A Slew Of Values Into MySQL From A Form
I'm working on a script to edit stored values which I will call on to change the appearence of certain parts of my website. I figured that I can store default values in MySQL, echo those values into a form, then edit whichever values I want, and have it updated in MySQL. However, I can't get the updating into MySQL part to work. The form displays everything the way it should, including the current values in the database. When I try updating it, instead of using the new value, it instead inserts blank space. I *think* it's because of my query, but I don't see why it shouldn't work, since I did define $values = $_POST['values'] at the top of the script. I don't know if it's my logic that's off, or my code, but I would appreciate any assistance. PHP Code:
View Replies !
MySql Querying Multiple Columns.
Trying to achieve a like function where the match is achieved if the data is contained in column1 and/or column2 but if the keyword is 2 or more words it looks at both columns not just the one (make sense - if not look at my examples) If the $q variable is Blue Widgets and I use the following query I will get rows returned if Column1 contains Blue Widgets Code:
View Replies !
Importing Html To Mysql Database
I'm preparing to convert my "old" non-dynamic html website to php and mysql. I finally found a mediumly fast way to turn the html pages into raw data, but it has html codes within the content that I want to stay within the database. For example, I have DIV and CLASS codes with quote marks (div id="fred" - p class="red") that I want to stay. I've read through the mysql documentation and understand that I can set the fields-terminated-by, fields-enclosed-by and lines-terminated by with characters, but I can't find which characters are allowed. I also am not sure about doubling the quotes in order to keep them ("") or adding slashes ("), or what. I did a test run with phpmyadmin to add a simple four field test text file to a table I set up with phpmyadmin. I tried changing from the default field separators of ";" to "^" and record ends of "#". Nothing. Code:
View Replies !
Querying MySQL To Search For Array Data
I have a problem with my php script. The script's task is to search an IP-Database with ranges as entries and find, in which range the entered IP is. OK, I've queried the MySQL-Results of the ranges into an array, containing the "IP ==> internalid" where internalid is the Primarykey of the table from which I can get more infomation about that range at a later point. The IP can be found in a range and so on.. Everythong works. But: How can I search the database for more than one entry, when the IP exists in more than one range? I really don't know how to do that, maybe my energy is nearly at "0" now,
View Replies !
MySQL - Splitting Similar Data To Two Tables And Querying As A Whole
Ok I am working on building my skills to convert my apps to LAMP (read I'm a semi noob), and there was one part I was thinking of. If I create two identical MySQL tables (we'll say, invoice and invoicearc) one will hold current period data and the other will hod out of period data - previous years stuff, which is only used in queries <5% of the time at most. Code:
View Replies !
HTML Form With PHP And MySQL
I'm building a content management system using PHP and MySQL so that we can add and remove projects from our website easily. I want several dropdown lists with the options Yes/No (or radio buttons, whichever is easiest) in them and depending on the users choice it will add their choice into the db. I have the Add page working fine, but the problem lies in the update page. if i go to my update page it pulls all the right information back into the HTML form from the DB until it gets to the dropdowns, which it doesnt like. How can i make it select the appropriate option from the dropdowns depending on the DB? If i submit the changes it wont update it either and gives errors from the dropdown code. Code:
View Replies !
Save Real HTML Tags Into My Mysql Database.
I want to save real HTML tags into my mysql database. I use $p = htmlentities($content); to convert the strange characters to real html. Then from another page i echo the content from the database and i see real html tags which is what i want.But in the database its still saved as:
View Replies !
Error Updating Html Text In A Mysql Database
I have a field in my database which needs to contain html code (for formatting of text, lists, and links). I can successfully add the data and view it on a webpage, but I cannot figure out how to edit it. I have read about magicquotes, htmlspecialchars, addslashes, etc, and I have tried various combinations of these without any luck. My code currently looks like this: $id = $_POST['id']; $myhtml = $_POST['myhtml']; if (!get_magic_quotes_gpc()) { $myhtml = addslashes($myhtml); } $query = ("UPDATE products SET myhtml="$myhtml" where id="$id""); $result = mysql_query($query); And the error is: 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 'myhtml=" Can anyone help?! or advise where I might be going wrong?
View Replies !
How To Populate HTML Form From PHP/MySQL
I have found many examples of how to access an HTML text field from PHP, but cannot find the reverse - how to load an HTML form from a MySQL database. Specifically, I have an HTML form which contains several text boxes that correspond to the fields in a MySQL file. What I want to do is call a PHP form that reads one record from MySQL and then populates all of the HTML fields on the calling form. The call to MySQL is not a problem - that works and I can use "Echo" to verify that I have successfully read a record. Now, how do I get that data back into the original HTML form?
View Replies !
Deleting A MYSQL Record From Within An Html Form
Just rebuilt an admin tool in PHP (originally built in asp) for a news section of a site. The problem is: My delete records php page is set out in an html form, with each news story expressed with a checkbox. normally i'd put a <a href="delete.php?id=<? echo $row->id; ?> </a> alongside the record, but i need to have it work in a form. What action should the form have, and how do i get the form to process the deletion process with the correct news story checkbox selected?
View Replies !
Sending Html Form Data To Mysql
I have no formal training with programming besides a few intro classes in college(6+ years ago). 1) I created a mysql db called "myphr" and a table called "form_data" with id,name and email as the elements in the table 2) I created a "form.html" web form to have some put in their name and email to submit to the data base: Code:
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 !
Changing Variables Values Based On Condition
I am submitting a form field that has several dropdown menu that pass information that is dynamiclly changed in javascript through a menu function so the values for each dropdown menu equal numbers ranging from 0-12 when i submit the form and tried to read what was in the form fields for processor I get a reply such as 0 or 1 or 2 Instead of AMD ATHLON XP 1900+ which is what I want into read and store into my session. PHP Code:
View Replies !
Run A Select Statement Based On Array Values?
I have an array that has x number of values. I want to run a sql statement x number of times using the next array value each time. Basically I have a query that displays results based on a search. The result of the search is a list of names, the trouble is for reasons beyond my control the names are in a single db field as "FirstLast". I want to take this value and match it up to another table that has the first and last names in separate fields. So far I have extracted the results from the first query using a while loop, the resulting array is called $name_search: Code:
View Replies !
Use The If Statement To Make A Display Based On Comparing Two Values
I am trying to use the if statement to make a display based on comparing two values, pretty simple. Here's what I have: if($ffor > $fagg) echo " (L)"; elseif($ffor >= $fagg) echo " (D)"; elseif($ffor < $fagg) echo " (W)"; elseif(!empty($row[8])) echo " "; What I want it to do is not return any results when $ffar and $fagg are empty/null results. I am struggling as it keeps returning null values as a (D).
View Replies !
Form Processing To MYSQL Database
That database and table are set up. The table is called 'reservations' and it has 5 fields to hold the input data. However I keep getting this error: Parse error: syntax error, unexpected $end in /Applications/xampp/xamppfiles/htdocs/paul/reservation_send.php on line 38 The funny thing is though that there is no lone 38, the script finishes on line 34. Any ideas on this one? Is the coding I have used the best way to write data to a mysql database or does someone have some better code. I am finding this quite frustrating as you would think it would be an easy enough script to do but I don't seem to be having much luck with it. Code:
View Replies !
|