Forums

How I load the information of Section, Categories, Content

luiscamp 20 Aug, 2008
Hello

I'm trying to make my form better and I have a question.

How I make a dynamic form that load first the sections of the page, then send with that value selected shows the categories and with that value selected show the titles of the articles in that category.

I have to make another .php file that load in arrays all the data with a direct query to the database an then sort them ?
$sql = 'SELECT `id`, `name` FROM jos_sections order by `id`;  
$sql = 'SELECT `id`, `name`, 'section' from jos_categories order by 'section';
$sql = 'SELECT 'title', 'catid' from jos_content order by 'catid';


And then take all this data and make a different script for sorting😲 ?
How I pass this data to the form?
There is another option for this?

Thanks for all your help😀
GreyHead 21 Aug, 2008
Hi Luiscamp.

I'm not sure that I understand the question. You want to show a drop-down list of sections; then when a section is selected show a drop-down list of categories for that section, . . .

I'd do it with a single form and switch options I think. Form html something like
<?php
switch ($level) {

  case 'category':
    // show section name
    // show category drop-down
    $level = 'category';
    break;
  
  case 'article':
    // show article list
    $level = 'article';
    break;

  case  'section':
  default:
    //show section drop-down
    $level = 'section';
    break;
}
?>
<input type="hidden" name="level" value="<php echo $level; ?>" />


and OnSubmit before something like
<?php
if ( $level == 'section' && $_POST['section'] != "" ) {
   // we have a section selected
    $_POST['level'] = 'category';
    showForm($_POST);
    $error_found = true;
} elseif ( $level == 'category' && $_POST['category'] != "" ) {
    // we have an category selected
    $_POST['level'] = 'article';
    showForm($_POST);
    $error_found = true;
} else {
    // select a section
    $_POST['level'] = 'section';
    showForm($_POST);
    $error_found = true;
}

Bob

PS Not tested or complete!
luiscamp 21 Aug, 2008
Thanks 😀

I'll work with that, I will make test with that code and then I post XD.
This topic is locked and no more replies can be posted.