0
我需要更正使用PHP顯示鏈接的方式,出於某種原因,我的鏈接子類別以下面的格式顯示。PHP鏈接顯示問題
http://localhost/index.php&sub=sub1
http://localhost/index.php&sub3=sub3
當他們應該以下列格式顯示。
http://localhost/index.php?cat=2&sub=sub1
http://localhost/index.php?cat=2&sub=sub1&sub2=sub2&sub3=sub3
有人可以幫我糾正這個問題嗎?
這裏是PHP代碼。
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]);
我該怎麼做呢?自從我編寫PHP以來,這已經有一段時間了 – HiThere 2010-08-17 02:53:01