I'm newbie so I hope u'll help me. I need to update my SQL with this PHP form. I googled a lot, but problem is i have name in variable: ($rowclanky["id"])
And simply just can't handle it... Tried a lot of things like adding slashes, etc. But I still couldn't make it. Can someone help me how to figure this out? Thanks a lot guys and sorry for my English.
<form method='POST'>;
$sql = "SELECT id,text FROM clanky";
$result = $con->query($sql);
if ($result->num_rows > 0){
while($row = $result->fetch_assoc()) {
echo "<input type='text' name=".$row["id"]." value='".$row["text"]."'><br>";
}
}
echo "<input type='submit' name='send' value='Upravit'><br> </form>;
}
$rowclanky is not defined anywhere
$rowclanky["id"]
should be
$row["id"]
And
$rowclanky["text"]
should be
$row["text"]
You have not declared the $rowclacky variable. Try the following:
while ($row = $result->fetch_assoc()) {
echo "<input type='text' name=".$row["id"]." value='".$row["text"]."'><br>";
}
notice that you are setting the results from "fetch-assoc()" to the variable $row. So when you try to access the columns in you need to get them from the $row variable.
Hopefully this helps.