Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2008, 09:23 AM
Authorized User
 
Join Date: Feb 2007
Location: IIT Kanpur, UP, India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default array with where condtion

hi everybody.....!

I am working in php5 and I have an array, getidArray(index as 0, 1, 2..ect)with value of auto increment number(primary key).

I want to use mysql query as

select firstFieldname,secondFieldname from tablename where id=$getidArray;

note that: $getidArray[0]=primary key1;
           $getidArray[1]=primary key2;
            $getidArray[2]=primary key3...etc

How to use array in where condition?

Please reply as soon as possible

Thanks in advance




 
Old May 13th, 2008, 09:21 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Code:
$sql = "select firstFieldname,secondFieldname from tablename where id IN (" . join(',',$getidArray) . ");";
Any use?


--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk




Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Array to Array comparison pavel Pro VB 6 0 March 24th, 2004 06:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.