Jump to content


Photo

MySql table name stored in php


  • Please log in to reply
2 replies to this topic

#1 Dawie

Dawie
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationCape Town, South Africa

Posted 02 November 2003 - 08:12 PM

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

#2 Alien

Alien
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 03 November 2003 - 07:52 AM

I am not sure why you have parentheses.

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

#3 Dawie

Dawie
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationCape Town, South Africa

Posted 03 November 2003 - 10:11 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users