PHP variables as table name
Posted by:
alen.pros
Date: May 29, 2005 01:14PM
Is there any way I could use php variable as table name in mysql select query? Example:
<?php
$razred=$_POST['droprazred'];
$odjel=$_POST['dropodjel'];
$odabrano=$razred.$odjel;
$upit="select * from '$odabrano'"; /*this doesn't work, is there any way I could make this work, or it's just mission impossible*/
$link=mysql_connect("localhost","username","password");
if ($link) {
if (mysql_select_db("test",$link)) {
if ($rezultat=mysql_query($upit)) {
while ($zapis=mysql_fetch_assoc($rezultat)) {
echo $zapis["id"].". ".$zapis["name"]
."<br>";
}
mysql_free_result($rezultat);
}
else echo "Trazena tablica ne postoji.";
}
mysql_close($link);
}
?>
Subject
Written By
Posted
PHP variables as table name
May 29, 2005 01:14PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.