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