How to concatenate values from an array to form an SQL q?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pravonline
Forum Newbie
Posts: 2
Joined: Wed May 24, 2006 2:18 am

How to concatenate values from an array to form an SQL q?

Post by pravonline »

Dear All,

I would like to how to concatenate the values from an array to form a complete sql query, say for example

The array looks like this :

Arraytest[1] = "SELECT"
Arraytest[2] = "*"
Arraytest[3] = "FROM"
Arraytest[4] = "TABLE1"
Arraytest[5] = "WHERE"
Arraytest[6] = "NAME"
Arraytest[7] = "="
Arraytest[8] = "BUSH"

And from this i need to form a SQL qury like this ""SELECT * FROM TABLE1 WHERE NAME = 'BUSH'" and need to pass this into a Variable "$test", number of subscript of this array depends upon the length of query, can any one guide me how to do this? Since i'm a mainframe professional and new to this technology!!

Thank you,
Antony
User avatar
neogeek
Forum Newbie
Posts: 24
Joined: Sun May 14, 2006 4:24 am

Post by neogeek »

Code: Select all

$test = implode(' ', $Arraytest);
Hope that's what you are looking for.
pravonline
Forum Newbie
Posts: 2
Joined: Wed May 24, 2006 2:18 am

Thanks Mr.Neo Geek

Post by pravonline »

Thank you so much Mr. Neo Geek, That is what exactly i want, Thanks once again for your valuable reply,

Regards,
Antony :D
Post Reply