thedigicraft / Atom.CMS

Atom.CMS
56 stars 52 forks source link

Ajax: Call Php Page Inside Navtabs with Php While Loop #239

Closed ozyedi closed 2 years ago

ozyedi commented 6 years ago

Hi, i have complicated problem for me. I am listing variables from database with php while loop. Bootstrap navtabs listing that variables like menu. I want to call pages with ajax which navtabs link id's are same with page names. How can i call that pages with ajax in while loop? Need jquery code to do that. Can you help me about to do that please?

<ul class="nav nav-pills nav-stacked" role="tablist">
    <li role="presentation" class="active"><a href="#all" aria-controls="all" role="tab" data-toggle="tab">All</a></li>

<?php   
    $q='SELECT * FROM categories';
    $r = mysqli_query($dbc,$q);
    while($categorytabs = mysqli_fetch_assoc($r)){  
        echo '<li role="presentation"><a href="#'.$categorytabs['category'].'" aria-controls="'.$categorytabs['category'].'" role="tab" data-toggle="tab">'.$categorytabs['category'].'</a></li>';
} 
?>

<div class="tab-content">
  <div role="tabpanel" class="tab-pane fade in active" id="all">All</div>
<?php 
    $q='SELECT * FROM categories';
    $r = mysqli_query($dbc,$q);
    while($categorytabs = mysqli_fetch_assoc($r)){
        echo '<div role="tabpanel" class="tab-pane fade" id="'.$categorytabs['category'].'">'.$categorytabs['category'].'</div>';
    } 
?>

</div>

In mysql database; I have a table. id and category column.

In server; I have pages same name which database table columns variable for example i have a page : bed.php , i have category column name is bed (same)

i'm already asked that question to stackoverflow. Here is link https://stackoverflow.com/questions/47993982/ajax-call-php-page-inside-navtabs-with-php-while-loop

Can you help me about that please?

Thanks already

creptor commented 6 years ago

I can't understand you completly, but I get what you're trying to do.

You can use SPF, wich is what youtube uses to load content without reloading the page, or pure javascript (check reference links).

SPF jQuery Documentation Stack Overflow question Json vs Html Example of loading html with javascript