Hello Jack,
you simply forgot an echo.
<?php echo join(....); ?>
Also, have a look at print_r, which is very very useful for debugging.
Greetings from Germany,
Christian
Jackson Linux schrieb:
Hello all,
I am a newbie trying to build a set of links to content in a db. I am
connecting with the db and seeing the proper number of rows. if I echo
out the values of $id and $sidebar I see that they take on the id# and
text of the last entry in the database. I'm trying to make the script
get each of the rows, until there are no more, and echo out the info I
need for each row. Please can someone tell me where I'm going wrong?
(the variables spelling out the db connection information are in a
prepend file, and work.)
Thanks in advance,
Jack
<?php
$conn = mysql_connect($dbserver, $dbusername, $dbpassword);
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("$dbname")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$sql = "
SELECT *
FROM sidebar
";
$sidebar = array();
$result = mysql_query($sql);
if (!empty($result)) {
while ($sidebar = mysql_fetch_assoc($result)) {
$id = $sidebar['sidebar_id'];
$linktext = $sidebar['headline'];
/* Build sidebar.*/
$left_sidebar[] = "<li class='menu-item'>- <a class='sidebar-link'
href='{$_SERVER['PHP_SELF']}?s={$id}'
title=\"{$linktext}\">{$linktext}</a></li>";
}
}
else {}
mysql_free_result($result);
?>
<html><body>
<ul><?php join("\n\n", $left_sidebar); ?></ul>
</body></html>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php