Jump to content

Recommended Posts

I'm using a web service call, my response comes back as an array:


stdClass Object ( [contractVehicle] => Array ( [0] => ITSchedule70 [1] => ITCommodityProgram ) )


I then need to hand this response off to anther developer who needs to know that "ITSchedule70" is the selected Contract Vehicle (actually there could be more than one, this only returns one for now), so he can insert it into a SQL query against a MySQL database (to match "Products" with the right "Contract Vehicle".

 

So basically how do I do that? How to wrap it up and send it off, and how to insert a query?

Link to comment
https://forums.phpfreaks.com/topic/291045-use-php-array-with-sql-query/
Share on other sites

Hand to "another developer"... how? Are you going to print it out on a piece of paper and send it to them through the mail? Or maybe hire one of those airplanes that flies around cities trailing a banner? Because you have a PHP object right now and I can't figure that's very far from what you actually need.

Sorry, I should clarify. Its my inexperience with PHP.

 

So now I have this object, how do I use it to write PHP in a SELECT query. Specifically, using WHERE condition the contract vehicle should be ITSchedule70 in the query statement.

More clarification:

 

Evertime the user submits the form, I'm making a call to the web service. So it might return 0=>'ITSchedule70'  or   1=>'ITCommodityProgram'  or   2=>'OtherContractVehicle'

 

I've got 4 contract vehicles.

 

Based on that returned contract vehicle, I need to use that as a WHERE criteria to return results from a Products table.

 

So like:

 
SELECT * FROM `product` WHERE `contact_vehicle_id` = 2
 
So the important point is the WHERE needs to be dynamic, because on the fly.

Well, if I use the term "ITSchedule70" in the query, that seems to defeat the whole purpose. Everytime the form is submitted, the web service call will return a different contract vehicle. "ITSchedule70" is one of many.

 

I believe I need to pass a variable in the WHERE criteria, so the SQL query doesn't have to be written each time.

 

Not sure, perhaps I'm thinking of this the wrong way? Or missing something fundemental?

 

Does that make sense?

I think you are missing something.

 

Yes, you need something variable in the query. Presumably the ITSchedule70 thing. Of course you can't write it directly in the query.

But for you, just for now, write it directly in the query, okay? When all that works you can worry about using a variable or whatever.

Edited by requinix
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.