I access the current page title as $row['title']; which is within a while loop.
Now how do i access the title of the next row in database? something like $row['title'+1]; gives me an output as 1
Accessing the next title
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
superdezign wrote:Show some code. The while loop tends to handle data retrieval from the database for us.
Code: Select all
$countviews = mysql_query("UPDATE wow SET views=views+1 WHERE id=$page");
$sql = mysql_query("SELECT * FROM wow WHERE `trusted` = 0 ORDER BY `id` ASC LIMIT $from, $max_results");
while($row = mysql_fetch_array($sql)){
echo "<!--start-->";
echo "<font size=3><b>";
echo $row['title']."</b><br /></font>";
echo "<font size=2>";
echo "Contributed By ";
echo $row['contributed_by'];
echo " on ";
echo date("jS F Y H:i:s", $row['date'])."<p>";
echo $row['content']."</p><br />";
echo "<!--end-->";
}echo $safeurl->make_safe_url($row['title']+1);
//should give me the next title- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Do you understand what this line is doing:
It gets the rows one by one and replaces $row with the current row's data. Within the while loop, everything that you do with $row is done to a particular row's data in your result set. After there are no more rows, $row == null, thus the while loop ends.
$row is no longer usable after the loop until you assign some other value to it.
Code: Select all
while ($row = mysql_fetch_array($sql)) {It gets the rows one by one and replaces $row with the current row's data. Within the while loop, everything that you do with $row is done to a particular row's data in your result set. After there are no more rows, $row == null, thus the while loop ends.
$row is no longer usable after the loop until you assign some other value to it.
Yes sir, i understand what it does completely... i am using a mod rewrite structure as example.com/abc/1/2/3/content-title-of- page-1 and when the user clicks on the next button it should point to example.com/abc/1/2/3/content-title-of- page-2 that means content-title-of- page-2 etc. is the title of the next page
example the page looks like
now in the above example the next page link (url will have the title of the next page according to the mod rewrite i have used in combination with scottayys human rich code posted on the forum) so how to display the link for next and previous
example the page looks like
Code: Select all
within the while loop{
TITLE of current page
CONTRIBUTED BY abc
on some DATE
CONTENT
}
<< Previous Page ------ Next Page>>