Please one of you help me to understand how to do the second Select tag from the form.
This is the page: http://localhost/aproapetot-nou/add_page.php
The idea is when I click on Select category and select one(Bancuri is the only one fill in), on the second one Select tag I want to see the subcategories only from Bancuri. Each category, first Select tag should show diff subcategories, from the second Select tag. Like on the cars sites: you select a car, then from the second select, you select the model.
So this is the form:
<p><label for="category"><strong>Categorie</strong></label><br />
<select name="category"<?php if (array_key_exists('category',
$add_page_errors)) echo ' class="error"'; ?>>
<option>Select One</option>
<?php // Retrieve all the categories and add to the pull-down menu:
$q = "SELECT category_id, category FROM categories ORDER BY category ASC";
$r = mysqli_query ($dbc, $q);
while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
echo "<option value=\"$row[0]\"";
// Check for stickyness:
if (isset($_POST['category']) && ($_POST['category'] == $row[0]) )
echo ' selected="selected"';
echo ">$row[1]</option>\n";
}
?>
</select><?php if (array_key_exists('category', $add_page_errors))
echo ' <span class="error">' . $add_page_errors['category'] .
'</span>'; ?></p>
<p><label for="subcategory"><strong>Subcategorie</strong></label><br />
<select name="subcategory"<?php if (array_key_exists('subcategory',
$add_page_errors)) echo ' class="error"'; ?>>
<option>Select One</option>
<?php // Retrieve all the subcategories and add to the pull-down menu:
$q = "SELECT
categories.category_id,
categories.category,
subcategories.subcategory_id,
subcategories.category_id,
subcategories.subcategory
FROM
categories
INNER JOIN subcategories ON categories.category_id = subcategories.category_id
WHERE subcategories.subcategory_id=". $_GET['id'] ." ORDER BY subcategories.subcategory ASC";
$r = mysqli_query ($dbc, $q);
while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
echo "<option value=\"$row[0]\"";
// Check for stickyness:
if (isset($_POST['subcategory']) && ($_POST['subcategory'] == $row[0]) )
echo ' selected="selected"';
echo ">$row[1]</option>\n";
}
?>
</select><?php if (array_key_exists('subcategory', $add_page_errors))
echo ' <span class="error">' . $add_page_errors['subcategory'] .
'</span>'; ?></p>
<p><label for="title"><strong>Titlu</strong>
</label><br /><?php create_form_input('title', 'text',
$add_page_errors); ?></p>
<p><label for="content_page"><strong>Continut</strong></label>
<br /><?php create_form_input('content_page', 'textarea',
$add_page_errors); ?></p>
<script type="text/javascript">
CKEDITOR.replace( 'content_page' );
<p><input type="submit" name="submit_button" value="Adauga"
id="submit_button" class="formbutton" /></p>
</fieldset>