select statement with variables ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Can someone tell me why this select is wrong please---ive tried everything.
the $cat is the tablename .


$query=" SELECT title FROM $cat WHERE id='$id'";



full script below

<?
$id=$_POST['id'];
$cat=$_POST['cat'];
$db="flash_software";
$link = mysql_connect('localhost');
if (! $link)
die("Couldn't connect to MySQL");

mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());

$query=" SELECT title FROM $cat WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_num_rows($result);

$i=0;
while ($i < $num) {
$title=mysql_result($result,$i,"title");

?>
<table width="300" border="1" cellpadding="10" cellspacing="0"
bordercolor="#666666">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#333333">
<h3><font color="#FFFFFF" size="3">Edit and Submit changes</font></h3>
<form action="update_record.php" method="post">
<input type="hidden" name="ud_id" value="<? echo "$id" ?>">
        Title:
        <input type="text" name="ud_title" value="<? print "$title"?>"><br>

<input type="Submit" value="Update">
</form>
</td></tr></table>

<?
++$i;
}
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux