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


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





Multiple Select From Listbox And Execute A Sql Query Select Statement


Supposing i have a html form with 2 listbox and i name it status and resolution.

So it goes <select name='status[]'>... <select name='resolution[]'>

Then i have a another php page.
$status = $_POST['status'];
$resolution = $_POST['resolution'];

Now my question is, how do i do the sql query statement?

mysql_query("SELECT * from bugs where status=$status and resolution=$resolution");

The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.




View Complete Forum Thread with Replies

Related Forum Messages:
Execute An Update Query Based On The Results Of A Select Query
I'm trying to execute an update query based on the results of a select query... This doesn't work - any ideas? This is the code I'm trying to get to run (it updates all products which are set to arrive by a certain date if that date has arrived or passed - and there are products that should and should not be updated in the db this is being tested with...): Code:

View Replies !
Select Statement With Multiple WHERE Clause
I want to select multiple rows from a table based on the user's id. For example,

Rob - 100
John - 101
Sarah -102

$query = "SELECT * FROM Users WHERE userID=&#39100;' AND userID=&#39101;' AND userID=&#39102;'";

How do I write it so that I can select all three users, based on their ID at the same time?

View Replies !
Select Query Validation & Else Statement
Using GET and a simple SELECT query, I am selecting the url to a pic from the database. If no url is present in the db (ie no pictures have been uploaded) then the script should echo 'Photo not on file'.

Seems that regardless of how I validate and echo the results, the script will echo the first condition of the if / else statement. When there is no pic url in the db instead of echoing 'Photo not on file' it echoes a blank image. Code:

View Replies !
Search Multiple Tables With One Select Statement?
I have a search form in PHP for MySQL.

Is it possible to search multiple tables with one select statement?

View Replies !
Select Case Statement In Odbc Query
i am attempting to write a complex query which requires a case statement. The query is put together as a string in php before being passed to access ( clients choice) with odbc_exec(). However, the addition of the case statement throws up a syntax error.

I have checked the syntax against ms's support pages and several other sites on the net to no avail. Am I mistaken in thinking that such complex queries can be used in this way. Having used IIF statements before I assumed they can and have found no documentation to suggest otherwise.

View Replies !
If Condition In A Select Query Statement Plus Concatenation
i am trying to use an if condition with the following select statement and at the ened trying to concatenate all the three variables to one under $strSQL Code:

View Replies !
Multiple Select Query
I'm trying to make a page where you can view all users or narrow them down by country.

The problem I'm having is selecting several countries. In other words intead of finding users from either country 1 or country 2 I want to be able to see users from countries 1,3,4,9,32. Code:

View Replies !
Multiple SELECT COUNT()'s In One Query?
I'm creating a script that, fairly often throughout, I need to use a SELECT COUNT() query on two seperate tables - this seems to be slowing the script down quite a bit, and if the script remains this slow, it won't be of much use to me...which would be very bad!

Is there anyway to combine these two to grab the COUNT() value from both in one query?

View Replies !
Listbox Select
What I want to do is when the user selects a name from a listbox pass the "eid" value to the next page for processing. So far I can get the list box populated but can not get the pass to the next page part. I am not sure how to do this part..... Below is the code i have so far..

include("datacon.php");
?>

<select name="fieldName">
<option>=&quot;&quot;&gt;Select One

<?

$querydrop = "select eid,Name from eid";
$resultdrop = MYSQL_QUERY($querydrop);
$numberdrop = mysql_Numrows($resultdrop);

if ($numberdrop>0)
.................

View Replies !
Select Value From Listbox
In my form i have a listbox which indicates the extract size of my zip file that is to be created. The option values in the listbox is hard-coded and not taken from the database.

However, one of the option values are stored in the database, as a default extract size, which is one of the values of the hard-coded listbox.

And i would retrieve the default extract size from the database and make the option value selected, to show it is the default value. My question is how do i select a value in the listbox using php? Code:

View Replies !
SELECT Error: No Database Selectedin Query: SELECT * FROM Schedule
I got the above error message after reading FAQ #10 which applied to my first error. The thing is, I thought I had selected a database. This script is copied from a tutorial, and I'm just too new at this to spot my error. PHP Code:

View Replies !
Select Query Problem - Multiple Tables
I have 4 database tables. I want to perform a query to loop through each table and display the results under the relevand heading as below. Code:

View Replies !
Multiple Queries - Query To Select * From Reviews
My displayreview.php file queries the Reviews table: displayreview.php?id=67 The query here then looks up all the fields for ID 67, simple stuff. My problem is, I wanna do a second query on the Reviews table underneath for related items (say, if there are reviews of the same band/record label.) I want the query to select * from Reviews where, say, Record_Label=$Record_Label (as already defined in the first query), so that the results would display all other reviews for records released on Review 67's record label.

View Replies !
Select Statement - Select Random ID #
I have made up a page that pull info on 13 branches of stores onto one main page. It's basically there to display all the branches on one page... then you click on the one you're interested in and then you go to a more detailed page.

Back to the main page. On the top, there's kind of a featured branch that has a bigger picture and bigger title but it's still getting pul pulled from the same table etc etc etc.

In order for me to avoid favortism to one branch (and for other branches to start complaining) I want to ramdomized the order every time someone came to page but I have no idea how.

right now I have a super simple select statement.

View Replies !
Listbox Select Question
Below is the code i am using to populate a listbox.

echo('<select name"course">');
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo "<option>".$row['course_name']."</option>";
}
echo('</select><br /><input type="submit" value="go" /></form>');


The table scheme is:

course_id int not null auto_increment
course_name char(150) not null

Is there a way with php to reference the course_id? I can do $course_name = $_POST['course'] just fine but cant figure out howto pull course_id out.

View Replies !
How To Display Images On A Frame, When Select The Options From Listbox?
I'm using xhtml to create the listbox. What i want is, when clicking on the options from the listbox, different option will show different image on the frame.

View Replies !
Switch Statement To Execute Query
I'm trying to pass variables through multiple forms and then execute an MySQL query. All variables and forms must pass through a switch statement. Does anybody know what I'm doing wrong or if this is even possible? I'm not quite sure that I understand the array scenario here or if this thing could even work. I tried $_GET['post'] and $GET_['submit']......

View Replies !
Select Statement.
how do i get the code to only alter the last comment that the user posted last only
witihn the last comment page thay posted.

at the moment the user can goto any comment page and alter the last comment
but i need it to only alter the last comment within the comment they just posted to.

the only thing i can think of is to make another database field and enter the user's information ie date_added to the new field and cross match it with the below select statement.? Code:

View Replies !
Select Statement
My statement is :

$result = mysql_query("SELECT * FROM properties WHERE city = '$city' AND beds LIKE '%$beds%' AND baths LIKE '%$baths%' OR state = '$state' AND beds LIKE '%$beds%' AND baths LIKE '%$baths%' OR  zip = '$zip' AND beds LIKE '%$beds%' AND baths LIKE '%$baths%'  ORDER BY date DESC LIMIT 0,8");

View Replies !
Variable In Select Statement
Hi,

I want to do the following:

Select ID
From tablename
where name='$name'

How do I do this in PHP?

View Replies !
Select Statement Problem
I am having a problem with simple select statement When I run this statement in my PHP program.. no result..

$sql= "select * from zipcodes where zip between $pluszip and $minuszip";

But when I run the below statement I get the results..

$sql= "select * from zipcodes where zip between 12345 and 12456";

I tried this one also, but no result

$sql= "select * from zipcodes where zip between '$pluszip' and '$minuszip'";

I tried echoing pluszip and minuszip and i am getting the values printed. I am having trouble with passing it on to the select statement.

View Replies !
Versatile SELECT Statement
My SELECT statement below works if I have made an actual selection for the area_ID, but when I generate the page initialy no selection has been made yet which results in zero hits for the current version_ID. Do I need to make an additional SELECT statement and remove PHP Code:

View Replies !
Error In Select Statement
I have the following SELECT statement which aims to select data from the database for a month ago today however im getting an error message as shown below. SELECT STATEMENT

$dbQuery="SELECT * FROM data WHERE ReportedDate BETWEEN date("Y-m-d", strtotime("-12months")) AND date("Y-m-d", strtotime("-11 months"))";

ERROR MESSAGE: Parse error: parse error, unexpected T_STRING

View Replies !
Run A Sql (select) Statement On A MySQL DB
I am trying to run a sql (select) statement on a MySQL DB, using the sum function...
It keeps returning a value that I know is not correct (in fact it is 1.3356959598149e-315)...

The statment is: Select sum(domain_cost), sum(domain_charge) from table_name;

I know the answer should be about $12,000, but it is clearly not giving me this... Is there a formatting that needs to be included in the statement.

View Replies !
Password() And Select Statement
problem in retrieving a row form a table that I created in
mysql db.
I insert these values in the table
'Bell',password(ģ«').
But the problem is in my php application I cant retrieve this row
because the password that I pass dosn't match the password value in the
table.
this is the code that I wrote in my php application

$user = $_POST[username];
$pass = $_POST[password];
$q = mysql_query("SELECT * FROM admin WHERE username = '$user' and
password =PASSWORD('$pass')");

if(mysql_num_rows($q)==0){
echo "Acces denied. User not allowed to connect.";
mysql_close();
}
else
{
echo
"<script>window.location.replace('administrator2.php')</script>";
}

View Replies !
Select Distinct Statement
I have a question about the following PHP script - I got it off a web
site tutorial on how to count users logged into your site - my
question is the $PHP_SELF variable - it writes the name of the web
page to the 'file' field in the table - I don't understand why it is
doing that - I mean, isn't the SELECT DISTINCT statement only pulling
those records from that one web page? I guess I just don't follow what
it is doing with that SELECT DISTINCT statement?

$timeoutseconds = 300;
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;

$php_SQL = "INSERT INTO online SET timestamp='$timestamp',
ip='$REMOTE_ADDR', file='$PHP_SELF'";
$php_resultID = mysql_query($php_SQL, $php_linkID);

$php_SQL = "DELETE FROM online WHERE timestamp < $timeout";
$php_resultID = mysql_query($php_SQL, $php_linkID);

$php_SQL = "SELECT DISTINCT ip FROM online WHERE file = '$PHP_SELF'";
$php_resultID = mysql_query($php_SQL, $php_linkID);
$php_users_online = mysql_num_rows($php_resultID);

if ($php_users_online == 1)
{
print "<BR>$php_users_online user is currently online";
}
else
{
print "<BR>$php_users_online users are currently online";
}

View Replies !
Select Statement Not Valid?
I'm doing a search via the passing of values throught the url. I'm having a problem with the select statement. If i enter the values and the match (side1='$valueSide1' AND side2='$valueSide2') portion of the statement the correct values are returned.

But if I reverse the values and the do match (side1='$valueSide2' AND side2='valueSide1') then no match is returned. I've verified through command line that the statement works.
Does it look like my statement if formatted correctly? Code:

View Replies !
Variable Select Statement
I would like to have a form that gives the user choices for selection
parameters for email, printing etc.

A real simple example:

Give me all ______ who ______ when _______ where _______

I can figure this out if all of the selections are filled, but NOT if
they just decide to use only one of the selection choices.

I'm sure this is idiotic, but I'm really new to php and my ideas are
writing checks my programming skills can't cash.

View Replies !
Simple SELECT Statement
I have a dbase with some gigs that has a date field. The SELECT statement currently says...

QuoteSELECT * FROM `Gigs` ORDER BY `Eventdate` ASC LIMIT 3

which works fine but I also want the statement to only show gigs that havent happened yet or that are > than today's day. I tried WHERE Evevntdate > CURRENT_DATE or something along those lines but so far havent got it to work.

View Replies !
Strpos In A Select Statement
I am trying to query a Access database using the following code but I get an SQL error Syntax error (missing operator) in query expression. Is it possible to use strpos in a SQL statement?

pro_id is a field in the database whose value is 489

$valves = 489;

$SQLQuery = "SELECT * FROM Products WHERE strpos(".$valves.",pro_id,1) !== 0";

View Replies !
Select Statement With A NULL
I have forgotten how to do this. I have SELECT CONCAT(A, ' ', B) as C . If A or B is NULL this select fails. What do I need to do so it won't fail.

View Replies !
WHERE Clause In SELECT Statement
I am having a wierd problem. In a Select statement, I have a WHERE clause similar to:
SELECT * FROM stickers WHERE state=$state.

I have some links that have the argument: ?state=TX or ?state=KY.

When it trys to load that argument, I get a:

Error: Unknown column 'TX' in 'where clause'

The column name in MySQL is 'state' but for some reason it thinks TX is the column name. Can anyone tell me what I am doing wrong?

View Replies !
Looping Through Select Statement?
Let's say I have a table consisting of 100 rows. I want to return at least 60 rows where I retrieve every 3rd row. Is there a way to say if you reach the last record before returning 60 rows, then loop around? Code:

View Replies !
ORDER BY Using SELECT Statement
I have a top songs of the year voting script. When a user votes on a song, it adds +1 to the current song count. For example,

artist song votes
U2 Song Title 12

The problem is, when I do my SELECT statement to get the songs, in order of most votes down, it doesnt show them correctly. Here is my SELECT statement: Code:

View Replies !
Using Array With Select Statement
I know I would use an array somehow but how can i do a select statement where status would = 1, 2 or 3

I have it like this and not working cause I know it needs an array:

$result1 = mysql_query("SELECT * FROM tools where status=&#391; || 2 || 3");

View Replies !
Select Statement Not Showing
I'm trying to write a select statement where it returns all the postcodes that are within a given distance either side of a certain point. This is my code:

PHP Code:

$query3 = mysql_query("SELECT Pcode FROM postcodes WHERE Distance BETWEEN '$max_distance' AND '$min_distance'");

I have a table called postcodes with the fields Pcode and Distance (among others), and I have defined $max_distance and $min_distance.

I can't work out how to display the results. I'm not sure if it will be in an array, if I have to include a Loop or what. I have tried a number of different ways but none are working!

View Replies !
MySQL Select Statement
$query = "SELECT DISTINCT albumName FROM fotoPhotos, fotoUsers WHERE fotoPhotos.userid = fotoUsers.id AND fotoUsers.username = ".$username." ORDER BY albumName ASC";

I don't get an error message. The variable $username is set and exists in the database.

But there is something wrong that I cannot fathom.

View Replies !
SELECT ... INSERT Statement
I am trying to write a query to duplicate an order in our eCommerce application here. I could have sworn I wrote a query JUST like this before and it worked, but for some reason this is not working. My query looks like this: Code:

SELECT 1141139101, orig_cart_ordr_hdr.ordr_po_num, orig_cart_ordr_hdr.ordr_requested_date ...
FROM cart_ordr_hdr AS orig_cart_ordr_hdr
WHERE orig_cart_ordr_hdr.ordr_id=33
INSERT INTO cart_ordr_hdr (ordr_received_on, ordr_po_num, ordr_requested_date, ...)

There are about 50 fields in the query, but I just listed a few in my snippet of the query here. We're running MySQL 4.1.7 on this server. Any ideas?

View Replies !
A Simple Select Statement
I have the folowing table:
-----------
| content |
-----------
|id |
|parentId |
|title |
-----------

I want to select all the table records but I want in the ParentColumn to
return the title instead of the ID.

If it was in two different tables I would doit using SELECT * FROM t1,t2
WHERE t1.id = t2.parentId BUT they are in one table.

View Replies !
Select Statement Not Working
Can anyone see what I am doing wrong with this select statement;

"SELECT f_company_name, month(f_date), COUNT(f_baggage) as ct FROM found  GROUP BY MONTH (f_date) WHERE f_company_name = "yes" "

View Replies !
How I Write A Select Statement
how would i write a select statement, where i only want to retrieve the records where the "startdate" (held in DB) is less than 7 days old from the current date.

View Replies !
Select Statement Into An Array
I am looking to place the results of this query into an array and was wondering how this is done?

SELECT e.ethnicity, count(s.ethnic_id)
FROM tbl_ethnicity e, tbl_student s
WHERE e.ethnic_id = s.ethnic_id
GROUP BY s.ethnic_id

View Replies !
Maximum Lenght Of Select Statement
Can anyone tell me what the maximium length of a SELECT statement can be. I am coming from Foxpro where 8100 char was the limit. Part of my program is a query builder and I need to build a query from a series of drop down lists users select values from.

View Replies !
List Data From A Select Statement
I have a page where I am trying to list data from a select statement. However, I am only getting one record from this SQL statement in a PHP script, but over 3200 records with the same statement in phpMyAdmin. Am I doing something wrong? PHP Code:

View Replies !
Question Regarding A MySQL SELECT Statement
I tried hunting for a MySQL specific NG and didn't find one but I did
see that MySQL questions get asked here. If this isn't appropriate and
you know of an appropriate NG then that would be great.

In one table I have inventory...
table name is "inventory"
columns are..
-----------------------------
item_number item_name
-----------------------------
1 radishes
2 carrots
3 potatoes
4 oranges
etc..etc

Table two is "sold"
------------------------------
date item_number
13Mar 1
14Mar 4
15Mar 2
16Mar 1


What I am querying is the table "sold" for the Unique items (1,4,2)
and then retrieving their names from table 1.

My query below isn't working..
SELECT item_name FROM inventory WHERE inventory.item_number =
sold.item_number;

I am just now starting to get into complicated MySQL queries and
actually the more I learn about it the more I love it.

View Replies !
PHP, ODBC, SQL Server Select Statement
I am having a problem getting results back from a SELECT statement
using the script below. The field names contain decimals and I am not
sure wether or not this is causing the problem or not?? I am
connecting to a SQL server db using ODBC, first time connecting to SQL
server but have been using ODBC to connect to Access db's for years. I
have entered the field names just as they are in the table and I have
tried replacing the spaces and decimals with underscores but still
recieve the same error. Anyway, my simple script and the error that I
am recieveing is below. Any help would be greatly appreciated..

$connect = odbc_connect('cabngsql', '', '');
if (!$connect)
{
echo "couldn't connect";
exit;
}
$query1 = "SELECT fol no FROM Protocol.folder";
$result1 = odbc_exec($connect, $query1);
while (odbc_fetch_row($result1)){
$folder = odbc_result($result1, 1);
echo "$folder";
}
?>

ERROR: SQL error: [Microsoft][ODBC SQL Server Driver][SQL
Server]Invalid object name 'Protocol.folder'., SQL state S0002 in
SQLExecDirect

View Replies !
SELECT Statement Syntax For Variables
the statement below isn't returning the expected results. I've echoed it at runtime and the variables are missing. I presume it's just the syntax?

$query = "SELECT field FROM database.table WHERE email='$e' AND password='$p'";

View Replies !
Etrieving All Columns From Select Statement
I was able to utilize overlib to help create pop up windows for selected rows of data.Ā  However not all of the pop ups are working, my guess is that some of the information in the select statement is causing an issue. Code:

View Replies !
Writing An INSERT ... SELECT Statement
I have used this same format of an INSERT ... SELECT statment many times, and once again I'm trying to use it to creat a copy of an order. However, this query is not working on the live site. It works just fine when I run it on my machine and on another server though of course. Code:

View Replies !
Basic Select Statement Issue.
can anyone see anything wrong with this sql statement? I am getting no rows returned despite the fact that I have a record that meets the criteria.

$sQuery="SELECT * FROM tblPeople where 'fldPersonemail' = 'mike@hotmail.com' ";

View Replies !
How To Use Switch Statement In Select Tags
I want to use a switch statement to select a value in a list/menu. I have 1000 values in the list/menu and i want to select one value for example Code:

View Replies !
Incorrect Syntax In Sql Select Statement
I have this piece that is not working right and I can't figure out what I am doing wrong. Code:

View Replies !

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