I have this site that selects info that is displayed.
I have a small problem:
A text is a related to a certain category (kid). The text can include more than one page. If it is page one the text has sid=1, if it is the second page it has sid=2 and so on.
If you look at the code below I have a query where I select and print the $rubrik (the title of the site).
I would now like it to print out a link to the 2nd, 3rd, 4th page if there actually is one, after the title. something like echo "$rubrik - $sid";
So if the text has for example kid=1 and there's one post with sid=1 and a second one with sid=2, it should display the first text (sid=1) and then create a link to the second page.
If there is only one page it should only display that page.
<?
$pid = $_GET['id'];
$visa = "SELECT presentation.pid, presentation.Rubrik, presentation.texten, presentation.kid,
presentation.sid, kategori.kid, kategori.kategori FROM presentation INNER JOIN kategori on presentation.kid
= kategori.kid WHERE presentation.pid='$pid'
ORDER BY kategori.kategori ASC";
$result = mysql_query($visa,$db_link);
$rows = mysql_num_rows($result);
for($index = 0; $index< $rows; $index++) {
$pid = mysql_result($result,$index,"pid");
$rubrik = mysql_result($result,$index,"Rubrik");
$texten = mysql_result($result,$index,"texten");
$kid = mysql_result($result,$index,"kid");
$sid = mysql_result($result,$index,"sid");
$kategori = mysql_result($result,$index,"kategori");
echo "$rubrik";
}
the db-structure
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| pid | int(11) | | PRI | NULL | auto_increment |
| Rubrik | varchar(70) | YES | | NULL | |
| texten | longblob | YES | | NULL | |
| kid | int(11) | YES | | NULL | |
| sid | int(11) | YES | | NULL | |
+--------+-------------+------+-----+---------+----------------+
how the info in the db could look like
mysql> select * from presentation where kid=2;
| pid | Rubrik | texten | kid | sid |
| 1 | Test | information | 2 | 1 |
| 4 | Company | more info | 2 | 2 |