
September 7th, 1999, 02:18 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
well I have figured (it is not that difficult) out a way:
Here is my code:
<body bgcolor=YELLOW>
<h1>Item Index</h1>
<?
mysql_connect("localhost", "userid", "");
$query = "SELECT category FROM items ORDER BY category";
$result = mysql_db_query("mydatabase", $query);
if($result) {
$number = mysql_numrows($result);
echo "Item Index: ($number) <ul>";
$j = 0;
$icat = "";
WHILE ($j < $number){
$category = mysql_result($result,$j,"category");
if ($j == 0){
//if it is the first item set icat value
$icat = $category;
//depending on the keyword clicked the correspondig page will be opened, at this moment this is not complete and need some work here
echo "<li><A href='$category.php3'>$category</A>";
}elseif ($category <> $icat){ //icat value has changed
$icat = $category; //again set icat value
echo "<li><A href='$category.php3'>$category</A>"; //display as a href link
}
$j++; //increment the value.
}
echo "</ul>";
} else {
echo "No data."; //if not data
}
mysql_free_result($result); //clear the array
?>
..some footer code here
</body>
|