I am building an editor for a blog and each post will be categorised.
When the user clicks on a post title from the first dropdown menu and presses Ga (go in Dutch), then the page reloads with the second category dropbox selected to the category associated with it, and display all the other categories in the same dropbox.
The second dropbox that contains all the categories will allow the user to change the category of article. I am able to get both dropboxes populated, but I don't know how to get the selection part working.
I think that the (isset($_POST['Ga'])) is missing something, but I don't know.
Any suggestions?
<?php
if (isset($_POST['Ga'])) {
$db = new mysqli("dbhost", "username", "password", "dbname");
$query = "SELECT c.catid , a.titel , c.cat FROM artikelen a JOIN Categorie c ON c.catid = a.catid where c.catid = a.catid";
$result = $db->query($query);
while ($row = $result->fetch_assoc()) {
if ($row ['a.catid'] = ['c.catid']) {
$selected = ($row['catid'] == $result);
$resultofcat = echo "<option value=\"".$row["catid"]."\" ".($selected ? " selected=\"selected\"":"").">".$row["cat"]."</option>";
}
}
}
?>
<?php
$link = mysqli_connect("dbhost", "username", "password", "dbname");
$db = new mysqli("dbhost", "username", "password", "dbname");
$query = "SELECT c.catid , a.titel , c.cat FROM artikelen a JOIN Categorie c ON c.catid = a.catid";
$result = $db->query($query);
echo "<form action='test.php' method='post' enctype='multipart/form-data'>";
?>
<select id='subcatsSelect'>
<?php
$result = $db->query($query);
while ($row = $result->fetch_assoc()) {
echo "<option value='catid'> {$row['titel']}</option>";
}
?>
</select>
<select id='categoriesSelect'>
<?php
$result = $db->query($query);
while ($row = $result->fetch_assoc()) {
$resultofcat = ("<option value='{$row ['catid']}'> {$row['cat']}</option>");
echo $resultofcar;
}
?>
</select>
<input id='Ga' type='submit' value='Ga'name='Ga' />
What I have tried:
I have tried searching through Stackoverflow with no luck and tried asking this question there, but haven't received any responses.