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




Arrays, Query Results And Select Box


I want/need to pre-select a drop-down box with a value if it's present in both a lookup table and user account table. After wrestling with this for a few hours I give up.

i know this can't be this complicated, but apparently i'm missing something, so if anyone can suggest a way to go about this i'd be a little more sane. The idea is to have the user value already selected then when they change the value i'll update their account.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Using Arrays With Mysql Query Results
im currently in the process of making a piece of code that will firstly take all the data from a table in mysql and then assign it to an array. This data will consist of several different rows of data each with different infomation for each field in the table.

i want to be able to use an array in a loop so that depending on which number of the loop is on will change the infomation that is assigned to a certain array. Code:

Paginating Random Select Query Results
I am just starting with PHP/MySQL and using Dreamweaver MX 2004.
I am selecting a subset of records from a table, then ordering them using RAND() and then displaying 6 at a time on a page. So far so good but there is one major problem, namely, when you move from page to page viewing the results the query is rerun for each page which means that you end up duplicating results.

What I want to be able to do is run the query once and then page through the returned results without duplication. Also to be able to go back & forth between pages and see the same set of results.

Here's a simplified example: Suppose I have 12 records (call them A - L).
The query : SELECT * FROM Table WHERE Criteria = 1 ORDER BY RAND()
Which returns: D F K A L F J H G C B I
So my pages should show the following:
Page 1: D F K A L F
Page 2: J H G C B I

And I should be able to switch back and forth between these pages and always see exactly the same records each time.
However what I see at the moment is:

Page 1: D F K A L F
Page 2: F B C A E D (Note duplicates from Page 1 because query has been re-run)
Page 1: C B F A K L (Note duplicates again plus results not the same as previous visit to Page 1)

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.

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:

Use Arrays To Page Through Results?
I've got a search facility that interrogates an SQL database then shows the results 30 at a time. Currently, when you go to the next page of results it has to run the query all over again, because there is no way of handing the resultset to the PHP file. So I wondered if there was another way of doing it.

I'm tempted to use mysql_fetch_array and create a multi-dimensional array full of result rows, then hand that around, but so far cannot find out how to hand a PHP array as a variable to a PHP page.

IS this possible, or am I barking up the wrong tree? Or is there a better way of doing this?

Splitting Results Using Select Tag
when i can make a choice out of let say 10 in a form:

<select name=choice>
<option value=1>1
....
<option value=10>10
</select>

when i submit it will split up de results after the first loop but when i choose "next results" it does not see the value anymore and returns nothing, so how can i solve this?

Splitting Select Results Into Pages In PHP
I'm new to PHP and Mysql, so I was hoping someone more experienced could help me with this one.

I've gone through most of Kevin Yanks excellent tutorial on Databases, but I haven't found an answer to my question.

I'd like to split the text results of a select command into a number of pages. I'd like to display 10 jokes on one page, and then ten jokes on the next and so on.

Anybody have any ideas on how to do this? I've been searching the web for most of the morning, but haven't really found the answer I needed and I was hoping somebody could give me a hand.

How Can I SELECT Results Visible To Crawlers?
I have seen a few site search result pages come up in Google etc. when similar search criteria were entered in Google as if they were entered in the site.

Sounds Good! I thought all dynamic output and database content was invisible to spiders.

I was thinking I could do every kind of category search on my site and save each page as a static HTML page, but it's heaps of time and there must be a better php way! Also I am not sure if they would be spidered at all as they wouldn't be obviously linked to.

Using Select And Where And Ordering Results Issues
I'm trying to show the most recent downloads added to my site and then ordering them by the last 5. The code below doesn't return any results. Any ideas on what i'm doing wrong? Code:

Is There A Quick Way To Compare The Results From Two Arrays And Note The Diffences?
is there a quick way to compare the results from two arrays and note the differences?

I have two identical tables in MySql (backup and current table) and I want to work out the differences between them (i.e. what fields are different). I could construct some long function, but I was wondering if anyone had a quick method (I am just learning PHP).

How Do I Return 10 Results Per Page Using SELECT Statement?
I'm wasn't sure whether to post this under the PHP or under the MySQL section of the forums. Since most people (I'm assuming) who write PHP script, also use MySQL, I thought I'd stick with PHP. I'm rather new to both PHP and MySQL and I'd be very grateful to anyone who can help me solve a problem I'm having at the moment. First, I'll give you an introduction to my little project...

I'm developing a database in MySQL that is used to store the song titles of all the MP3s I have on my PC. I've written a basic search feature that works well. The user has 2 options: Either he can type a special "!ALL" "parameter", that I made up, to return all the songs in the database or the user may enter a few characters in the textbox and select "song title" or "artist" etc. from a dropdown to search for a specific song title or artist etc.. Hope you are following so far? Say for example the user presses submit after typing "!ALL" to return all the song titles - there could be hundreds of results. What I want to do now is display 10 results on a page, then on the next page another 10, etc. (like a real search engine!). I've tried doing it with the LIMIT statement, but like I said I'm new to this and discovered that that is not the right way of going about it. My question is this: how would I go about returning 10 matches per page? Do I use hidden form fields? What would the SELECT statement look like? What would the PHP scripting look like to setup the "back" and "forward" navigation between the result for the search?

Select And Display Multiple Queries / Results
Howdy all, i've been looking through various sites / tutorials and through this php book I have here to try figure out whats causing this problem but haven't had any luck yet.

The problem is that its displaying the Designation as the link url instead of the jcode. Hope i explained this well. Above this bit of code has calls the individual Catagorys, if theres data in that catagory it will display it with whats below. PHP Code:

Taking SELECT Results And Turning Them Into An Array()
Does anyone know how take a mysql select statement and have the results placed into an array? I am returning 1+ rows and want to place those rows into an array so I can run a foreach() for each row and then run another foreach() for each column for each row? Code:

Displaying SELECT Results In A Formatted Table
I was wondering how to show a table with a max limit of 20 results per page. I have various data being pulled and its putting it in a table, but its displayed all in one row. I want to format it so its a 4 column/5 row table. With that I then want the page to generate a numbered list at the bottom that calculates how many pages it takes to show 20 items on each. Code:

SELECT Statement Results Into Text File
I am trying to create a text file based off the results of a query statement from a database. See code below:

$itemq = "SELECT sdlitm, sddsc1, sduorg, sdlnid, sduncs FROM F4211 WHERE sddoco = $ordernum AND sddcto LIKE '$ordertype' ORDER BY sdlnid";
$result3 = odbc_exec($connect, $itemq);
    while (odbc_fetch_row($result3)){
    $partnum = odbc_result($result3, 1);
    $desc1 = odbc_result($result3, 2);
    $qty = odbc_result($result3, 3)/100;
    $position = odbc_result($result3, 4);
    $uncs = odbc_result($result3, 5);
    $extcost = $uncs*$qty;
    $total = ($total + ($uncs * $qty));
    $filename = "$reportnumber.txt";
    $fp = fopen($filename, "w");
    fwrite($fp, "Activity Number: $reportnumber
");
    fwrite($fp, "Warranty Type: $reason
");
    fwrite($fp, "Customer Name: $custname
");
    fwrite($fp, "$qty $partnum $desc1
");
    fclose($fp);

Everything works fine until I get to the line:

fwrite($fp, "$qty $partnum $desc1
");

This line should actually print multiple lines into the text file as these are the line items from an order. There could be anywhere from 1 to 20 lines written to the text file. As it stands, the only line items written to the text file are those of the last line found on the order. The entrie script dealing with the text file are still within the confines of the while statement curly braces. How do I write these lines out in the text file??

Displaying Select Information From XML Search Results
I am new to both php and xml. I have a school assignment to update an existing php-based website where I have to display search results from an online library. I can use a url search which returns an XML file that includes tags such as position, title, url, description, date, etc.

I only want to display the title, url (preferably the title should be a link to the url), and description for all of the results on my website's search results (different template as well).

What classes/functions are available to help me do this? I would appreciate any guidance as well as links to online tutorials etc. that would point me in the right direction. I have read about the general aspects of php, and I have experience with Java and C; but I don't know about xml at all.

By the way, the website is running on the school server and has php version 4. I don't think I'll be able to install php 5 but I can probably upload some helper files or something.

Help Needed Using Arrays In Query
I am try to use an array in a MySQL query using the in function. This requires a "," between each array entry but not at the end of the array. I can get a "," in between but I am left with one at the end. How can I get rid of the last ","?

MySQL Query And Arrays
I have a 'links' category on Table A and I want to retrieve the links from the Table and display them in a list-like fashion when the page is called upon. How would I go about seperating the links from one another (there a space inbetween each link.. EXAMPLE: http://asdf.com http://asdasd.com http://asdfff.com), loading them into an array (or using the best possible method to acces them easily) and then displaying them in a list like fashion..?

Getting Too Many Results From A Query!
This is very peculiar -- for some reason, I'm getting 6-8 results from each
of these queries, although only one listing matches. I have a pair of forms
on one page:

<FORM>
Search for lastname: ____________ [Submit]
</FORM>
<FORM>
Search for email: ________________ [Submit]
</FORM>

This goes to a searchresults.php page:

if ($searchname !== "") {
$query="SELECT artistID,firstname,lastname,email,city,state,count ry
from artists WHERE lastname='$searchname'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
while($row = mysql_fetch_array($result)) {
$alt_artistID = $row['artistID'];
$alt_firstname = $row['firstname'];
$alt_lastname= $row['lastname'];
$alt_email = $row['email'];
$alt_city = $row['city'];
$alt_state = $row['state'];
$alt_country = $row['country'];
echo "<CENTER><HR>".$alt_artistID."<BR>"
.$alt_firstname." ".$alt_lastname."</A><BR>"
.$alt_email."<BR>"
.$alt_city.", ".$alt_state." ".$alt_country."<BR>
<A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS
LISTING?</A><BR></CENTER>";
}
}

The second section is identical except for:
if ($searchemail !== "") {
$query="SELECT artistID,firstname,lastname,email,city,state,count ry
from artists WHERE email='$searchemail'";
etc...
}

I don't understand why I would get 6-8 records when you can look at them and
see that all but one clearly do not match...?

Using Query Results
Can you use a queries results only once? In this script I'm looping through a query and saving some values in an array. A little further through the script I need to use the same query for output. When I loop through nothing is echo'd to the browser. When I output a row count it shows that the correct number of records, so they must still be there.

Query About Empty POST Arrays
I started programming in PHP recently and have a query about empty
$_POST arrays. I can see two scenarios when this could happen.

1. When some tries to directly load the page to which data is being
posted (for example, opening www.foo.com/xyz.php directly when a form
action is xyz.php)
2. When the user clicks the submit button without entering anything.

I am aware that Javascript validation can take care of the second case,
but it's unreliable. What is the accepted way of handling the above
situations on the server side?
Do I just reload the calling page if the array is empty?

Populating Arrays From MySQL Query
I have the following code: http://pastebin.com/746601

The field 'material' in 'is_material' contains multiple values for each
record in 'is_details'. Because of this I have used
'is_material_lookup' as a reference lookup table containing the
'style_code' and 'material_code' which refer to their full details in
the respective tables.

Currently I have got the script outputting all the details and one
material then in the next block of data, repeating the details with a
different material. What I would like to achieve is having 1 block of
data with a list of all materials in that, instead of the repeat, but
sadly I can't know exactly how to do it.

Mysql Query - Select Any
I have the following sql statemant to search a mysql database that gets
if values from a form with combo box's in.

SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =
hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND
hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND
hottubs.seatsto <= '%s' AND hottubs.shape = '%s' ORDER BY
$thesearchtype_search.

Everything works fine except I want to add a select "any" from the
shape combo box. I really need a way of cutting out the last " AND
hottubs.shape = '%s' " if the $_GET['shape'] = 'any'
Will this work using a variable as shown below??

IF ($_GET['shape'] != 'any' )
{
$shape = AND hottubs.shape = '%s'
}

SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =
hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND
hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND
hottubs.seatsto <= '%s' $shape ORDER BY $thesearchtype_search

I have only been doing php about a month so go gentle!

Select Query Between Dates
I would like to add a date restriction to this code PHP Code:

Select Query Problem
I use php4 and winxp.

This query works as expected:

$result = mysql_query("
SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby,
fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate
FROM events
WHERE
fdate between '$datefrom' and '$dateto'
and factive
and fpostdate <= curdate()
ORDER BY fdate, fpostdate
");

However, when I add the condition

!(strpos(fdetails,'$fsearchstring')===false),

$result is false.

$result = mysql_query("
SELECT feventid, UNIX_TIMESTAMP(fdate) as fdate, ftitle, fpostedby,
fdetails, factive, UNIX_TIMESTAMP(fpostdate) as fpostdate
FROM events
WHERE
fdate between '$datefrom' and '$dateto'
and factive
and fpostdate <= curdate()
and !(strpos(fdetails,'$fsearchstring')===false)
ORDER BY fdate, fpostdate
");

Even simpler stuff like:

'and strpos('abc','c')>0'

does not work.

I made two more discoveries trying to crack the problem.

&#390;=0', is an acceptable condition, while 'true' is not.

For the first query, $result does not return true, but 'Resource id #3'.

I have just started with php. What am I doing wrong?

Select Query For Keywords
I am connecting to an Access database. I have the following code that breaks the user submitted title into an array. I want to match only records that have only the array values, but can be in any order. For example:

User enters - "Purple People Eater"

Matching Records - "Purple Eater People", "Eater People Purple",...
but NOT - "The Purple People Eater", "Purple People",...

Here is my code: PHP Code:

Select Query / Loop
My users are organised in a table named 'users'. Each user is a member of a department, but some users are members of more than one department, so I have another table named 'user_department'. I have another table named 'submissions' int which users submissions are stored. Right now I am developing an archive of submissions. Generally speaking a simple query will do the job like this:

$query = "SELECT * FROM submissions WHERE status != 'Pending' AND sid = '$username' ORDER BY id desc LIMIT $from, $max_results";
$result = mysql_query($query);

The problem comes when I try to select only the submissions lodged by the users department. The point being that the department head can view all submissions lodged by his department. If the department head is only head of a single department, this would work:

$query = "SELECT * FROM submissions WHERE status != 'Pending' AND department = '$users_department' ORDER BY id desc LIMIT $from, $max_results";
$result = mysql_query($query);

But if the department head is head of more than one department, I start to get lost! I can loop through the 'user_department' table to find out which departments the user is the head of like this: Code:

Php Query To Select Min Date
im trying to get a minimum date from my database, the current way im doing it is:

SELECT * FROM events where Date > NOW() OR Date = '9999-12-12' ORDER BY Date ASC LIMIT 1

this works in terms of code, but it doesnt do what I want it to do. Its the ORDER BY Date, that is the problem: What I want to select is

The next date OR a date = 9999-12-12

I tried searching for a query like "select MIN date" but couldnt find anything on it, plus the date has to be in the future, hence the need for DATE > NOW()

quite confusing I know!! but any advice?

Query Results In 2 Columns?
I'm struggling to figure out how to do this properly. I have done a mySQL
query to extract a list of names, and done a mysql_num_rows to determine how
many results I've gotten. I want to split the list in to two columns. I've
created $percol = $mysql_num_rows/2 but I'm not quite sure how to "loop"
through the first half of the list, echo </td><td> and then list the
balance. Can anyone give me some guidance on how best to structure this?

Finding The Results Of A Query
I am working on a script that will query a database for a FNAME/LNAME
combo. If it finds the combo, I need it to do one set of instructions.
If it doesn't find it, I need it to do something else. What I can't
figure out is what variable to check against. Here is what I have for
the relevant part of the script:

$connection = mysql_connect($hostname, $username, $password);
mysql_select_db($databasename) or die ("Cannot connect to database"
..mysql_error());
$query="SELECT FNAME, LNAME FROM (table) WHERE FNAME=('$FName') AND
NAME=('$LName')";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close($connection);

I tried checking the value of $result to see if it changed depending on
whether or not it found the selection. It does not. I just can't figure
out what to use for:

if (some expression){
perform this code
}
else{
do this
}

Grouping Results Of Query
I'm brand new to PHP (just starting today to convert tons of
ColdFusion/Access code to PHP/MySQL). There is a function in
Coldfusion that I can't find an equivalent to in PHP. Here is
what I am trying to do:

If I have a query that results in this information:
State Firstname Lastname
Idaho Terry Pratchet
Vermont Dan Brown
Vermont Bob Smith
Virginia Alice Johnson
Virginia David Jones

I would like to output the info like this:

But all I can find in PHP is a way to loop through the query
and show every row... if you are familiar with Coldfusion,
what I am looking for is something similar to this:

<CFOUTPUT GROUP='State'>
#State#<BR>
<CFOUTPUT>
#Firstname# #Lastname#
</CFOUTPUT>
<BR>
</CFOUTPUT>

Is there a function that does this in PHP, or do I need to
write code that watches the value of 'State' and manually
takes care of things whenever it changes?

ODBC Query Results
Consider the following:

<?

$username = "foo";
$password = "bar";
$host = "db";

$connect = odbc_connect("$host", "$username", "$password") or die;

$query = "SELECT id, name, address, city, state, comments1, comments2
FROM data.table1, data.table2 WHERE id = ô˜'";

$result = odbc_exec($connect, $query);

while(odbc_fetch_row($result)){
$id = odbc_result($result, 1);
$name = odbc_result($result, 2);
$address = odbc_result($result, 3);
$city = odbc_result($result, 4);
$state = odbc_result($result, 5);
$zip = odbc_result($result, 6);
$comments1 = odbc_result($result, 7);
$comments2 = odbc_result($result, 8);
print("ID: $id<br>Name: $name<br>Address: $address<br>City:
$city<br>State: $state<br>Zip: $zip<br>Comments1:
$comments1<br>Comments2: $comments2<br>
");

}
?>

Only one record is returned from data.table1 (containing the id, name,
address, city, state, & zip). However, there are multiple records
returned from data.table2 (records from comments1 & comments2). What
is happening is that when I run this script, all of the data returned
from data.table1 is printed over & over again along with each record
returned from data.table2. How can I make it such that id, name,
address, city, state & zip are only printed once - and allow comments1
& comments2 to be printed multiple times for each occurance in the
database?

I've thought about just creating a second database query for the
records in data.table2, however I need the join I'm getting by using
the existing query.

For what it's worth, I'm connecting to a DB2 database using PHP /
Apache on Linux.

I'm confused by this.

Losing Query Results!
If I make a query;

$result = mysql_query($theQuery, $db);

and then make use of the query results like so;

while ($row = mysql_fetch_row($result)) {

//do something with query results}

I can't use $result again, I have to make another query! Why is this and is there any way around it?

Multiple Sql Query Results
I'm trying to do a query from 2 databases. Basically i have
catagories within 2 databases. If both catagories return 0 rows then it
does nothing but if one or both have rows returned then i need it to
echo a result. I guess where i'm wondering if there's an OR statement i
can use or something to that effect...

something like

if($numrows == 0 OR $numrows2 == 0) {
echo ('');
}else{
echo ('$result');



SQL Query - Results From Another PHP Page ?
Can I store this PHP code in another page, then refernece it on
multiple pages using Require or Include ???

//results from sql query
for ($i=0; $i<$number; $i++) {
$ID = mysql_result($result,$i,"ID");
$CompanyName = mysql_result($result,$i,"1");
$ContactName = mysql_result($result,$i,"2");
$Phone = mysql_result($result,$i,"3");
$HomePhone = mysql_result($result,$i,"4");
$MobilePhone = mysql_result($result,$i,"5");
$AltPhone = mysql_result($result,$i,"6");
$SecondContact = mysql_result($result,$i,"7");
$SecondPhone = mysql_result($result,$i,"8");
$ThirdContact = mysql_result($result,$i,"9");
$ThirdPhone = mysql_result($result,$i,"10");
$Notes = mysql_result($result,$i,"11")

Sql Query Results And Scrolling
I make a mySQL database query and display the first 10 results. Then
the user can click on "next" link to get the next 10 results. How can
I do that without issuing the sql query again? Can I keep the results
from the first query?

Query In PHP Won't Return Results In There's Only 1
$sql = 'SELECT `PageTitle` '
$sql .= 'FROM `Pages` '
$sql .= 'WHERE `PageID` = 1 LIMIT 0, 30'

I have run this query in MySQL control panel and it works perfectly.
When I try to do it via PHP I get no results.

If I select all rows (i.e I don't specify a "WHERE") I get one fewer
rows returned than there actually are.

Tabulating Sql Query Results
I'm trying to number my rows in the column named "Pos" but so far I not getting any success, someone please bail me out find below my script, this script displays my results fine but without my Positions (Pos); Code:

Combining Query Results
I have two queries which searches for any fixtures your clan (team) is in and then returns some information about the fixtures. Is there any way of combining these results and ordering them by date? Code:

Filtering Results With Php Query
This code works, but I don't know how to filter the results to where only one person is displayed..it displays all records with similar address or state or city, I would like to know how to make it display only one person when multiple search fields are entered.

I'm using PHP5, and I have searched the forums but I'm not sure exactly if I found what I'm looking for...I don't know much about php or mysql. Code:

Capturing/using Results Of Query
I would like to display/capture/use the URL's that are displayed on a web page after making a query to a forum.
What do I mean?

I am part of a forum that uses vBulletin.  One option is to display the forum topics that have had posts that day, i.e. active topics.

Essentially, when you click on the link:
http://www.somedomain.com/forum/search.php?do=getdaily

the resultant page has a list of the active topics, highlighted as links.

What i would like to do is capture/access that resultant page and use regular expressions to grab the URLs.  I can do the RegEx but I cannot seem to capture that resultant page.

How Do I Show Results Of A Query
I know how to connect to a Mysql table.  I want to run the query and show the results on my page.  I'll have about 25 different fields I need to show on the page.  Most of this information will be a couple of addresses. 

Basically, a billing and then a shipping address.  Can someone show me how to show some of this on a page?  I'll need to align all this stuff around the page. 

Filter Results Of Query
I am modifying some pages in CRE Loaded.

allprods.php list all currently active products and I added a manufacturers column that displays who makes that product.

I want to allow shoppers to filter the product list so that it shows only products from a particular manufacturer.

I have gone through several scenarios in my mind, but nothing I've thought of seems simple and bullet proof.

One of the issues is that the all products query includes all manufacturers.  If I were to put a variable in the query to select only a particular manufacturer, how would I code it so it does not interfere with the all products query?

Would logic based upon the value of a form action work?  If form action exists, someone wants to filter.  If not form action or form action = all, then they want the whole list. Seems like filtering a list is pretty common and there should be an easy solution.

Disable Passing Arrays In Query String?
Is there any way to stop PHP from turning a query string like this: ?var[] into an array when it is read by $_GET['var']? I have quite a few input validations that are easily screwed up by this strange (and apparently undocumented???) feature...

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?

Pass Array Into Select Query ?
I was wondering if it is possible to pass a php array into a mysql query rather than looping through each one eg:

//the array
$namesArray = array("Joe", "Jane", "Bob", "Mary", "Paul", "Eddie", "John");
//the sql
SELECT id FROM users WHERE name='$namesArray'

Query Select Dates More Than One Hour
i'm searching for the mysql query which can gave me frome DATE_TIME mysql
variable which lines are more than an hour

i can do that with days with
SELECT * FROM clients WHERE TO_DAYS(NOW())-TO_DAYS(date)>7



How To Corret This Mysql Select Query?
I convert some code from access to mysql. And I have a InboxMessage
table which has From and To field.
So, the query is like:
select * from InboxMessage where To=12
12 is user id.
This query works fine in access. But does not work in Mysql.
I think the problem is the field To, which must be a keyword in mysql.
So, how to fix this? I don't want to change the field, becuase this
will need to change a lot of code.

Query Date Range Select
how do i make a query that select between today and a week from today.


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