Jump to content

Archived

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

Dawie

MySql table name stored in php

Recommended Posts

Hi

 

I\'m storing a MySql table name in a PHP variable e.g.

 

$tbl = \"example\".$coy;

 

Why does:

$sql_command = (\"SELECT * FROM \'<?php echo $tbl; ?>\' WHERE id = \'$id\'\");

not work? Is there a way to do it? I unfortunately HAVE to store the table name in a variable cuz it is different for different companies.

 

Thanks

Share this post


Link to post
Share on other sites

I am not sure why you have parentheses.

 

try this

$sql_command = \"SELECT * FROM \" . $tbl . \" WHERE id = \'$id\'\";

Share this post


Link to post
Share on other sites

Thanks, I was a bit confused with the syntax.. but then, I\'m also a newbie =:)

Share this post


Link to post
Share on other sites

×

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.