Wednesday, 2 October 2013

getting checked value from checkbox thats taking data from database

getting checked value from checkbox thats taking data from database

I have problem to get to the checked value in checkbox. I have first query
that is taking names of the tables in database and second query that is
taking names of the columns of that tables. Names of the columns are
displayed in a checkbox, but i have problem to take that values from the
checkbox. I know I should use $_POST['kolona'] but somehow that variable
its not recognized:
if(mysqli_connect_errno())
{
echo "Error: Greška u konekciji";
exit;
}
$sql1 = "SHOW TABLES FROM db_baza";
$result1 = mysql_query($sql1);
if (!$result1)
{
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row1 = mysql_fetch_row($result1))
{
echo "<div id='blok'
style='width:200px;height:200px;background-color:red;margin:20px;float:left;'>{$row1[0]}"."</br>";
$tablename=$row1[0];
$sql2="SELECT column_name FROM information_schema.columns WHERE
table_name = '{$tablename}'";
$result2= mysql_query($sql2);
while($row2=mysql_fetch_row($result2))
echo "<form id='forma1' action='' method='POST'><input type='checkbox'
name='kolona[]' value='{$row2[0]}' />{$row2[0]}</br>";
echo "<input type='submit' name='submit' value='{$tablename}'/></form>";
echo "</div>";
}
if(isset($_POST['submit']))
if(isset($_POST['kolona'])
echo 1;
?>
So, I am just trying to echo number one, i will need it for other stuff
but just for the example.

No comments:

Post a Comment