PHP bağlantı görüntü sorunu

0 Cevap

Ben bağlantılar benim bağlantılar alt kategoriler altında aşağıdaki biçimde gösterilir nedense PHP kullanılarak görüntülenir şekilde düzeltmek gerekiyor.

http://localhost/index.php&sub=sub1
http://localhost/index.php&sub3=sub3

Onlar aşağıdaki biçimde görüntülenmesi gereken.

http://localhost/index.php?cat=2&sub=sub1
http://localhost/index.php?cat=2&sub=sub1&sub2=sub2&sub3=sub3

Birisi bana bu sorunu gidermek yardımcı olabilir misiniz?

Burada PHP kodudur.

function make_list ($parent = 0, $parent_url = 'http://localhost/index.php') {
    global $link;
    echo '<ol>';

    foreach ($parent as $id => $cat) {
        $url = $parent_url . $cat['url'];
        // Display the item:
        echo '<li><a href="' . $url . '" title="' . $cat['category'] . ' Category Link">' . $cat['category'] . '</a>';          

        if (isset($link[$id])) {
            make_list($link[$id]);  
        }               
        echo '</li>';       
    }       
    echo '</ol>';
}

$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"SELECT * FROM categories ORDER BY parent_id, category ASC");
if (!$dbc) {
    print mysqli_error();
} 

$link = array();

while (list($id, $parent_id, $category, $url) = mysqli_fetch_array($dbc, MYSQLI_NUM)) {
    $link[$parent_id][$id] =  array('category' => $category, 'url' => $url);
}
make_list($link[0]);

0 Cevap