Jump to content

[SOLVED] variable in connection statement


mottwsc

Recommended Posts

I'm trying to vary the connection in a statement based on a variable.  Since I could have 100 different connections or more, I don't want to use if-then logic (as below).

 

Instead of:

if( x == '001' )

{ $result = mysqli_query($cxn001,$sql) }

elseif( x == '002' )

{ $result = mysqli_query($cxn002,$sql) }

 

What can I use to accomplish this without the if-then construct?

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/176582-solved-variable-in-connection-statement/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.