Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Creating A Query From A Form


I'm struggling building a SQL query from the output of a form, i.e. the user inputs into a form which in turn decides the query.

I have never done this before and was just wondering if anyone had any links tutorials of something like this!? I have searched but haven't found anything too useful yet.

Basically all I want to do is for the user to pick from a drop down menu how they want a leaderboard displayed, i.e. top 50 results, bottom 50, 50 to 100 results, etc.

Do I just tie a complete SQL statement with the corresponding LIMIT info inside to a variable. The variable being the value of the chosen item in the drop down menu.

Pseudocode as follows:




View Complete Forum Thread with Replies

Related Forum Messages:
Passing A Variable Form A Form To A Mysql Query In A Php Script
I have a form set up with a dropdown list of values for a field "Genre" in my database

I can pass the variable to my php script. I know this because I use:

$Genre = $_POST['Genre'];

echo "<h1> Query result for Genre = ","$Genre", "</h1>";

And the page prints the appropriate value chosen from the form.

I'm trying to use the $Genre variable in a mysql query to select records which match.

My mysql query works when I use the following code:

View Replies !
Creating A Simple Form
I started this in the php section, but i think it needs to be here as well. I'm fairly certain i need mysql to do this, and my phpbb forums have mysql tables.

To reiterate the main objective, i simply want to create a form on a php page that has a field that says "Counter-Strike Name:" and a text box to input, then a submit button. After a user submits, i'd like it to take them to another php page where it displays their name and other users names who have signed up (it;'s for a tournament). I'd like the names to be saved on this page.

View Replies !
Creating An Order Form - New Table For Each One?
I'm trying to create a simple database using mySQL which will be used to create various web based order forms, these forms will be used multiple times.

The first table is for the item and is stuctured:
-------------
|Item |
|-------------|
|Description |
|Part No. |
|Article No. |
|No. Required |
-------------

The order options form is structured:

-------------
|Order Options|
|-------------|
|System Name |
|PPNo |
|Item |
|Item |
|Item...etc |
-------------

Each order options form can have any number of items within it.

View Replies !
Creating A Form That Allows A User To Choose What Column
I am trying to create a form that allows a user to choose what column to search through the data. The Database has many columns and the user wants to select - say - all clients that dr. fred diagnosed.

The column is ExamDoctor and they shouldn't have to learn sql to do this. (they're lawyers btw.) But they might need to see who was diagnosed on 2000-02-11, with the column name DateDiagnosed.

View Replies !
Query Form Bottom
How do I do a MySQL query from the bottom of the Table to the top?

View Replies !
How To Form Query When Field Name Has Spaces?
I'm doing a database for a dog-rescue group, and their info is being written by Front Page to a CSV file. Finally got an import CSV to MySQL to work. But all 160 fields have field names with numbers, spaces, apostrophes, question marks, etc.

I really don't want to hack into the source program to make the fields "nice" for MySQL if I can avoid it.

Here's a sample ...

SELECT * FROM appforms WHERE appforms.[18_Sex_of_ Dog_you_want?] LIKE 'female';

The WHERE clause needs something ... and I've tried all kinds of variations of quotes, etc. Don't know if the brackets are right either. Easy enough to test with the Query Browser, but I've run out of ideas!

View Replies !
Autocomplete Query For Search Form
$sql = 'SELECT * FROM `names` WHERE `name` LIKE "' . mysql_real_escape_string($partialTerm) . '%";';

My problem is that using the above a term "Da" will successfully match "Dave", "Daniel", "Davina" etc but it will not match "Steve Davis".

typing "Da" and got "Steve Davis" this would be wrong but I want it to show "Davis". Basically how can I search ALL separate words found in the name column of my MySQL table? Currently the query would only return the string "this is a an example" if I entered the first letter of the search term as "t". I want to be able to type "e" and be shown "example".

View Replies !
How Query Results[SELECT] Appear In Tabular Form,using An Image With Source FromFIELD
How query results[SELECT] appear in tabular form , using an image with source from the database table field "source" , and a link towards detailed page from the database table field "link" ? How to store image & link URLs IN THE DB TABLE?

View Replies !
Creating An A To Z List From Query
I am creating an a to z list - basically a count of all results that
start with the letter "A", "B", "C" .... and so on.

I am pretty poor at SQL so I am sure some brains out there can do
better than I have here. What I have is working, I just want to make
sure that it is optomized.


So let's assume I have some query "$query" that I want to run and get
an A..Z list based on column "$column".

Let's further assume that '$query" produces the following results, and
that $column is equal to "last_name".

last_name
---------------
Anderson
Bitmore
brown
Bogus

My AZlist query would look like this:

select * from
(SELECT count(alist.$column) as a from ($query) as alist where
alist.$column like 'a%' or alist.$column like 'A%' ) as a_result,
(SELECT count(blist.$column) as b from ($query) as blist where
blist.$column like 'b%' or blist.$column like 'B%' ) as b_result,
....
(SELECT count(zlist.$column) as z from ($query) as zlist where
zlist.$column like 'z%' or zlist.$column like 'Z%' ) as z_result;

And this retuns the following result:
a | b |...| z
--------------
1 | 3 |...| 0

Meaning that $query has 1 result where the first letter in $column is
"A" or "a", 3 results where the first letter is "B" or "b" and 0
results where the first letter is "Z" or "z".

What I am afraid of here is that "$query" is being executed 26 times
(once for each letter of the alphabet) . Is there a way to refine
this, or is MySQL (4.x and 5.x) smart enough to optomize this on its
own?

View Replies !
Creating An Optimal Query
What I am doing at present is displaying a list of topics such as on a forum main page. That data is in a table say "my_topics" for example
The list I am displaying also references data in another table say "my_images". Now each item in my_topics could reference zero or more items from my_images and they would need to be displayed alongside that topic. So each item in my_images has an id which is an index into the my_topics table.
At present I am dumping the entire my_images table into an array so I can access it without having to do multiple sql queries. I can't use "left join" as far as I know because the relationship between my_topics and my_images is one-to-many rather than one-to-one.Obvious downside is that as my_images table gets larger - dumping it to an array increases the memory usage of the script which eventually leads to it not working.

View Replies !
Creating Complex Query
its a booking form. user selects start date, finish date, and room type.
on my table i have roomInfo(roomNo, type, NoOfBeds);
occupancy(roomNo,DateStart,DateFinish,GuestNumber);
i am trying to do something like:
select roomNo from roomInfo where roomNO = single and roomNO not IN ...
cant do subselect its mysql 4.x version... would i have to do an outerjoin/innerjoin?

View Replies !
Creating Table From A Query
I have just put a forum up on my web site. The database tables were readymade via phpbb.
Because I want to send newsletters I need a table that just contains usernames and email addresses.
The table for users in the phpbb forum is huge so i did sql query:

SELECT user_id, username, user_email FROM USERS;

Which gave me all the information I need to send the emails on mass when this table is linked to a newsletter application.

however I am aware this is just a query. Can I create a new table from this query? So i just have a table of users and emails. If so how do I do it? I am using phpMyadmin.

View Replies !
Creating A Query Based On Dates
I am trying to write a query (in PHP) which selects from a database all of the items which are in the future. My query is as follows

SELECT * FROM news WHERE ((news.date)>$today ORDER BY date

where news is my database, news.date is the the field which holds the date for the item and $today will be replaced my current date. At the moment it seems to display all values, which suggest its not functioning properly.

View Replies !
Creating Non-existent Rows In Query With Join
I want to make report using PivotTable/CrossTab and I used an application to create it.
The problem is, I want to so show NULL value to the temp table that will be the source of my report.

I'm using this query:

View Replies !
MyISAM Vs InnoDB While Creating A Table Using Select Query
I have created a table using the select query.

****
for eg: create table table_name1 as select * from table_name2
****

now the created table is by default MyISAM format, what changes should i make to the query so that the created table is InnoDB.

View Replies !
Creating A Query That Will Only Return Records With Matching Counterparts
I'm using the table below as an example.

I want to create a MySQL query that will return only records that have matching counter-parts where 'col1' = 'ABC'.

Notice the 'ABC / GHI' record does not have a counter-matching 'GHI / ABC' record. This record should not be returned because there is no matching counter-part. With this table, the 'ABC / GHI' record should be the only one returned in the query.

How can I create a query that will do this?

id | col1 | col2
--------------------
1 | ABC | DEF
2 | DEF | ABC
3 | ABC | GHI
4 | DEF | GHI
5 | GHI | DEF

View Replies !
Help With Form
I created a contacts form. Uploaded the form, the database, and the
connection page to the remote server.
i tested everything out on my computer, win2000 localhost and everything
worked but after uploading and trying it out the following happens.
After filling in the form and clicking Submit I get ther following in a web
page:

Table 'contacts.contacts' doesn't exist

I don't know what this means. I have a data base named "contacts" and a
table named "contacts".

View Replies !
Dictionary In Sql Form
Does anyone know of any place where I can get what's basically a dictionary, in SQL form? Technically all I need is a list of words with the type of word (noun, verb, adjective, etc.) and synonyms, definitions aren't necessary.

View Replies !
Multiple Form Value
I am playing around with an address book mysql database I have put together but am having problems conceptualizing and putting down the search element.

I want users to be able to search on more than one field (fields aren't all in 1 table, they're spread out over 5/6 tables) and match all or partially. My brain goes round and round when trying to get a feel for this and keeping the code light and clean. Has anyone had any experience with this and can point me in a useful direction?

I have thought about having preset queries that users could select and then find the info they wanted, but it wouldn't allow users to select fields they wanted to search at will, it would be they would have to select a built-in query to run...it's not a bad system, but not flexible, very dependant on me writing the queries.

View Replies !
Refer To A Form
I'm using Access to view an SQL database and want to create a query that refers to a form in the criteria of one of it's fields. Usually in Access I would do this by:

Forms![FormName]![FieldName]
But this doesn't seem to work in the adp file. What I actually want to do is produce a single label for the current record in a form.

View Replies !
Repopulating A Form
Making a form where a patient will fill out check boxes and after submission would like to present their submitted form back if they choose the option and be able to edit the data entered. What I am wanting to do is repopulate the form, but the checkboxes will need a database with this information that will then go to a php script and take the values entered into the various checkboxes and check those values from the database that were entered origionally. So lets say the database haspid - int(5) auto_increment primary keypatient_first - varchar(30) first namepatient_last - varchar(50) last namearthritis - bool or what?copd - bool or what?tin ear -bool or what?What would be the best to check against to repopulate does a true false make sense or should it either be NULL or the actual condition (just kidding about the tin ear)?

View Replies !
Search Form Using AND
I've set up a search form that needs to search 2 fields, presumably using AND.
This is the code that i'm using:

<? $query_links = "SELECT dbfields FROM database WHERE search1<='$search1' AND search2<='$search2'";

If i replace the AND for OR, it works fine, in that it the 'search1' works. Basically, i need both search fields to be equal or less than the database field value.

View Replies !
Web Site Form
I want to have a form on my website, almost like a feedback form but not for feedback. It will be for getting info from customers. It will simply be about 30 fields that will need to post to a database. How hard is this with mysql? How would I do this on the web page? Is there a certain language I would need to use? Also is it possible to get an email everytime a record is added via the web form?

View Replies !
PHP &amp; MySQL Form
I have setup a copy of PHP and MySQL running of Apache on my PC and I need to know how to get this code working. It is a simple Submit Data form through to a database. Code:

View Replies !
First Normal Form, Etc.
i am trying to set up a database, and the book I am following seems to stress the proper organization of the database. I am pretty much trying to create a gallery. With a certain number of users, who can create separate albums, and store cards in them. The way I see i the database breaks down into 3 tables,

I have a users table (with an auto incrementing "user id" (primary key), email, password), a album table (with an album id number (primary key), album name, and a few other attributes specific to the table) and then a picture table (with a picture id (primary key), name of the picture, the image's path.)

My issue is not so much with creating and accessing the databases as it is with the actual design. I fail to see how I link the databases, i.e. how do I keep track of the user, who may have 7 albums, and 500 pictures, without putting their "user_id" in the album table, and a album_id with the corresponding cards.

If I do this, there seems to be redundancy which is not compliant with the normal forms (in particular the second)? For example, in my card table, there may be 500 card_ids for the same user number. Is this correct?

I know this seems like it requires telling me how to design my whole database... I guess what I need is a more graphical display of how to break down the data to be entered into a database. Because words aren't really doing it.

View Replies !
Cc And Bcc Emails In Form
I have the following code in which I want the ability to blind copy in a selection of email addresses so when the user submits the form it sends the main email to me and also to the other emails that are in the bcc part, here's part of the code:

$sender_name = removecrlf($sender_name);
$sender_email = removecrlf($sender_email);
$msg = "$sitename

";
$msg .= ""._SENDERNAME.": $sender_name
";
$msg .= ""._SENDEREMAIL.": $sender_email
";
$msg .= ""._MESSAGE.": $message

";
$to = "email@address.com";
$mailheaders = "From: $sender_name

At the moment when the users hits the send button it sends it to the adress shown in the $to which is: email@address.com

Now if I was to put all the email addresses that I want the form to be sent to in this $to part seperated by commas, it sends to all of them, however, it shows all the people who received the email who else it went to.

I have searched the net and numerous forums for an answer but found nothing, I tried $bcc and $cc etc but to no avail.

View Replies !
Form->database->web
Looking for script (probably php) that takes form data, enters in database (mysql or flat file) and outputs data to web.

The output to html table is what I'm unable to find in an existing script.

View Replies !
Upload Form
I am trying to use this code to insert the file into my dba but am not sure if it works i get errors. I want to create a table, then put the file into the table using a web baised form. If anyone knows how i can create a form to do this or if anyone knows of documentation on how to do this i would be greatful. Below is my code

<?
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp = fopen($tmpName, 'r+');
$content = fwrite($fp, $fileSize);
$content = fread($fp, $fileSize);
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}


include 'library/config.php';
include 'library/opendb.php';

// add a table to the selected database
$result="CREATE TABLE userfile (fileName VARCHAR(25), fileSize VARCHAR(25), fileType VARCHAR(15), fileSize VARCHAR(2000))";
if (mysql_query($result)){
echo "success in table creation.";
} else {
echo "no table created.";
}

$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed');
include 'library/closedb.php';

echo "<br>File $fileName uploaded<br>";
}
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>

View Replies !
Form Values Are Truncated
I'm building a member signup form. Fields that contain more than one word
are being truncated when being inserted into the MySQL table.

I'm using this code that I got from one of my PHP books.

$as_addr1 = addslashes($_POST['addr1']);$tr_addr1 = trim($as_addr1);

So, if I post "1122 Boogie St." it gets inserted as "1122". If I remove the
"addslashes" portion, only using trim, I get the same result.

Here's the query:
$query = "INSERT INTO subscribers
(email,password,fName,lName,addr1)
VALUES
('$tr_email','$tr_pass','$tr_fName','$tr_lName','$ tr_addr1'";

echo $query;

Here's the echo:
INSERT INTO subscribers (email,password,fName,lName,addr1)
VALUES('j@j.com','11111111','Jim','Johnson','78797 State')

I have other fields in the table that are doing the same thing. All fields
are varchars of varying length. Field "addr1" is varchar(50).

View Replies !
A Table Or A Form Field
If I have a db where people enter in their basic info...one of those things being the country they live in....Is it better to make a seperate table in the databases with the country names OR...just put the country names as options in the html form dropdown list?

View Replies !
Form One Server To Anouther
Im building a website which has a MYSQL backend. Im doing this on my laptop using XAMPP's PHPMyAdmin.
I have webspace which also has phpMyAdmin.

I have already started to build this databse on mylaptop and now i wish to uyplaod everything. Can someone please guide me through the proccess of transfering my MYSQL database on my laptop's webserver to my webspace using both PHPmyadmin

View Replies !
On Submission Of Form Data To Db
I have a php form for personnel, when someone fills it out and hits "submit", I want an email sent to me saying that someone has submitted an entry into the database.

View Replies !
Email Contact Form
Basically I have been asked to develop a contact form that stores all the users input i.e. Name, Message, Email add, etc, etc within the relevant fields that I have set up in MySQL DB. My problem is that no user input is being inserted into the fields when I export the DB table to Excel or PDF, the fields are there but the rest of it is blank!!!???

I have two web pages that 'handle' the email contact form. The 1st page (contact.php) is the form that posts user input and calls to action the 2nd page (contact_form_handler.php) which inserts the data into the DB table. Here is the code for both pages. Code:

View Replies !
Retrieving Data Through A Form.
I'm setting up a database and I want to retrieve data from the db through a form.

I currently have:

$sql = "SELECT * FROM Tasks WHERE t_id = '$_POST[t_id]'";

$result = mysql_query($sql, $conn) or die(mysql_error());

while ($newArray = mysql_fetch_array($result)){
$id = $newArray['t_id'];

echo "ID: $id <br>";

I don't think that the 'WHERE t_id = '$_POST...' part is correct, as the code seems to do what it is supposed to when I take that part out, it just doesn't do what I want it to do.

So.. to clarify; I insert a task id (t_id) into the form, hit the submit button, and it is supposed to show the results (echo "ID: $id <br>";). I hope this makes sense to someone. Code:

View Replies !
Returning Current Form
I have a table called `match` which holds details of games between teams.

`match` has:
`match_date`
`home_team`
`away_team`
`home_score`
`away_score`

I want a query to return the last 6 games (Win/Draw/Lose) for each team.
I am unsure if this can be done using my current table format.

View Replies !
Restrict Form Inputs
I have a site that uses a specific format for a username, how can I restrict or configure the input to a that format?

format would be as follows

[letter][letter][number][letter][letter]

It would look like this - KE4IAP

View Replies !
Create Table With Form
I have an html form that I want to create a new table when submitted. Is there a way to use input fields in the form ($username, $email) and create a table with it:

"CREATE TABLE ('username', 'email')(

various values

)";


View Replies !
Sql Based Contact Form
how would I create a contact form that would store the results in a sql databse, be able to see the results in a text file, and also would have a link to delete that result from the database in the results text file?

View Replies !
Web Form Data To Database
I have a root access to a virtual server running UNIX and SQL.I would like to have data from a web form go to a database and perhaps be emailed to me also.Typically some one would complete a form and attach a file and that is emailed to me using a cgi script.
I would like to have this data populate a database.

where to start.If someone could give me a basic list of what needs to be done,I can tackle those and then fine tune my questions.

View Replies !
Multi Page Form
Currently I have a form where, when a user logs in, the user info is displayed. if it's a new user, the form is blank and a row in inserted into mysql upon submit. The user is then taken to a confirmation page, and the user can go back and edit the info. I'm guessing that to continue this trend, I need to create multiple php pages for the form: step1.php, step2.php, step3.php....

However, if I wanted to run these forms off of one php page, may be using arrays and a loop... say, if step 1 for ( i; i<lengthloop; i++) loop array [step1][i], I would have to create the row in the database upon login, rather than as an aftermath.

View Replies !
Form Default Date
I have a MYSql database with an ASP VB form. I set up a text field and set the default value as: <%=date()%> but when I click the button to insert the record it tells me to check the sql error and lists my date field. My MySQL date type is date, not datetime. I am using Dreamweaver MX.

How do I set the default date so that it inserts correctly into mysql? Apparently I can't set the default value for the date field in the database structure because I link with an odbc driver.

View Replies !
Deleting Form 2 Tables
I'm using SQL not sure if this is different from MySQL

My problem is I have two tables which are related by ordernum:

Orders (table) OrderItems (Table)
l l
ordernum (field) ordernum (field)

I can't work out the sql delete statement which will delete the order from both tables. Can anyone see were I'm going wrong?

DeleteCommand="DELETE FROM [OrdersItems} INNER JOIN OrdersItems ON Orders.ordernum =
Orders.oredernum
WHERE [ordernum] = @ordernum">

<DeleteParameters>
<asp:Parameter Name="ordernum" />
</DeleteParameters>
</asp:SqlDataSource>

View Replies !
Using Form To Update 2 Tables
how to change ths script below so it can update the same cells in another table aswell the current table. in other words updates two tables at the same time.


<?php
if ($submit) {

require("db.php");
$con = mysql_connect("$db_host", "$db_user", "$db_pass");
$db = @mysql_select_db("$db_name",$con);
$sql = "INSERT INTO support (prod_code,prod_name) VALUES ('$prod_code','$prod_name')";
$result = mysql_query($sql);
echo "Thank you! Information entered. <a href=admin.php>Click Here</a>
";

} else{

?>

<form method="post" action="<?php echo $PHP_SELF?>">
Product Code:<input type="Text" name="prod_code"><br>
Product Name:<input type="Text" name="prod_name"><br>
<input type="Submit" name="submit" value="Enter information">
</form>

<?php
}
?>

View Replies !
How To Break The Text In Form
If the user is going to enter some information in a textarea in form. When i load this information into database i need the data to be entered as lines each of 60 charectars.

I mean when the user enters the data as a stretch, after every 60 charectars there should be a break which i should identify. Is there any procedure to do this.

View Replies !
Using Php And MySQL To Populate A Form
I am trying to use php to pull information from a table in mySQL and place it into a form. i have tried everything i can think of to do this. There are two files being used a .inc.php and a tpl. inside the .inc.php file is all of the php codeing and the .tpl file should call the information from the .inc.php. I placed the a from inside the .inc.php file using an echo tag to make it appear and it did but it wont show up in the correct place.

View Replies !
How Do I Put Form Data Into A Database?
I would like to take the form data submitted on a web page and put it into a database besides having the data emailed to me like is currently the case. I don't know where to start on this. I've never set up a database. Once in the database how do I get that data to my computer?

View Replies !
Automatic Form Generator
Does anyone know of a free software package that would query the schema of a MySQL table and automatically (or interactively) generate a PHP web form for querying/inserting/updating rows of the table? I've done some googling for this and the closest free thing I found was something called Xdobry that was too confusing and badly translated from German.

View Replies !
How Do I Sort Data Fro A Bad Form Into Something Useful?
I made a bad form with a form creation app in a hurry. Now I have a table that is nearly useless.

The form was meant to record teams for an upcoming volleyball tournament. I provided inputs for the school name, mascot, student, etc. The form app allows me to copy form elements, so I did.

The table now shows about 120 student, and grade, position, sorted by a form id (one for each team) but they are sorted by the record id.

Instead of:

Team | Student | Grade | Position | etc.....

I have:

record | name | value | etc...

I have tried some queries that just basically remove some superfluous column and GROUP BY record (that is the form id, so the third team to register has "3" under record.

Can I salvage this data by a clever query or am I looking at making a page via php to display the results?

Sample Data:

student name1 Curtis Geurts
student name1Tom Glasbergen
student name1Bill Lammers
student name1Marc Brouwer
student name1Kurt fledderus
student name1Nate Brink
student name1James Brouwer
student name1Scott Denbak
student name1Dave Stares
grade12
grade12
grade11
grade11
grade11
grade11
grade11
grade12
Player positionpower
Player positionsetter
Player positionmiddle
Player positionmiddle
Player positionpower
Player positionoffside
Player positionsetter
Player positionsetter

View Replies !
Prevent One Field Form Overlaping Another
I have the following table:

lesson {
id int,
lesson_start int,
lesson_end int,

PRIMARY KEY(id)
}

No lesson can overlap another. So I can't have rows like:

id | lesson_start | lesson_end
1 | 12:00 | 14:00
2 | 13:00 | 15:00

Is there any way to deal with it from the MySQL level?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved