hello,
I'm kind of new to the PHP-scene and I'm having difficulties with my first php-site
the situation:
I'm making a website were people view newsitems,
these newsitems are stored in a database ("postgresql")
every newsitem is stored in a category.
i would like to create a list of every category item in my database, so far my code looks like this:
<?php
include "connectie_db.php";
function showcategorie(){
include "connectie_db.php";
echo '<aside id="sidebar1">';
echo "<h3>Categorie</h3>";
echo "<ul>";
for ( $counter = 1; $counter <= 10; $counter += 1) {
$ZoekNaam = "Select cat_name from tovanu.categories where cat_id = '$counter'";
$res = $db->query($ZoekNaam);
if(MDB2::isError($res)){
echo "code: ".$res->getUserInfo();
exit();
}
$row = $res->fetchRow();
echo "<li><a href='#'>$row[0]</a></li>";
}
echo '</ul>';
echo '</aside>';
}
?>
problem number 1:
for ( $counter = 1; $counter <= 10; $counter += 1)
how can i make a for or a while loop so i can show al my categorie items?
problem number 2:
"<li><a href='#'>$row[0]</a></li>"
how can i make a the link, so i can view the newsitems within that category?
( something within the link, ? or something like that)
please explain your thoughts
any help would be appreciated!