Code: Select all
<?php
$nextlink = '<a href="?comicID='.($comicID+1).'">Next</a>';
$prevlink = '<a href="?comicID'.($comicID-1).'">Previous</a>';Code: Select all
if ($comicID== 1)Moderator: General Moderators
Code: Select all
<?php
$nextlink = '<a href="?comicID='.($comicID+1).'">Next</a>';
$prevlink = '<a href="?comicID'.($comicID-1).'">Previous</a>';Code: Select all
if ($comicID== 1)Code: Select all
$num_sql = "SELECT COUNT(*) FROM `comics`";
$num_query = mysql_query($num_sql) or die(mysql_error());
//num_query now holds the total amount of rows
if (!empty($_GETї'comicid']))
{
$sql_comic = "SELECT * FROM `comics` WHERE `comicid` = '".$_GETї'comicid']."' LIMIT 1"
$comic_query = mysql_query($comic_sql) or die(mysql_error());
$row = mysql_fetch_assoc($comic_query);
// run all your checks and determine what your links are going to have to look like...
}
else
{
// run your default stuff
}Code: Select all
<?php
$dbhost = 'localhost';
$dbname = 'silverf_website';
$dbuser = 'silverf_dan';
$dbpasswd = '*******';
$connection=mysql_connect($dbhost,$dbuser,$dbpasswd)
or die("Could not connect to server");
$db=mysql_select_db($dbname,$connection)
or die("Could not select database");
if (empty($_GETї'comicID']))
{
$query='SELECT * FROM Comic ORDER BY comicID DESC LIMIT 1';
}
else
{
$comicID = $_GETї'comicID'];
$query="SELECT * FROM Comic WHERE comicID= '$comicID' ";
}
$result=mysql_query($query)
or die ("Could not execute query: ". mysql_error());
//Get the results
$row=mysql_fetch_array($result);
extract($row);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Spin City 17 - <?php print($comicTitle); ?></title>
</head>
<body>
<?php
$nextlink = '<a href="?comicID='.($comicID+1).'">Next</a>';
$prevlink = '<a href="?comicID='.($comicID-1).'">Previous</a>';
print($comicTitle.'<br>');
if ($comicID==1)
{
print($nextlink.' | Previous');
}
elseif ($comicID='SELECT * FROM Comic ORDER BY comicID DESC LIMIT 1')
{
print('Next | '.$prevlink);
}
else
{
print($nextlink.' | '.$prevlink);
}
?>
<br>
<img src="<?php print($comicURL); ?>" alt="Spin City 17">
</body>
</html>Code: Select all
elseif ($comicID='SELECT * FROM Comic ORDER BY comicID DESC LIMIT 1')Hmm...it seems you are correct. Anything you can suggest?magicrobotmonkey wrote:This line is always going to return true.Code: Select all
elseif ($comicID='SELECT * FROM Comic ORDER BY comicID DESC LIMIT 1')
That's assuming I will remove an entry....but since I'm also working on a script to add comics, perhaps there could be a way of deleting them from the script, too. Any suggestions, perhaps?timvw wrote:now we'll wait untill you remove an entry..
so comicids become fe: 1, 2, 4, 5 and your script doesn't work anymore if you go from 4 to 2.
Code: Select all
$query='SELECT comicID FROM Comic WHERE comicID > '.$comicID.' ORDER BY comicID DESC LIMIT 1';
$result=mysql_query($query)
or die ("Could not execute query: ". mysql_error());
//now see if there was one
if(mysql_num_rows) != 1)
{
//no next comic so no link!
}
else
{
//there is a next comic, so display the link and the id of the next comic is...
list($nextComicID) = mysql_fetch_row($result);
//now use $nextComicID in your 'next' link
}Code: Select all
(SELECT comicID FROM Comic WHERE comicID = '$comicID' LIMIT 1)
UNION( SELECT comicID FROM Comic WHERE comicID < '$comicID' ORDER BY comicID DESC LIMIT 1 )
UNION( SELECT comicID FROM Comic WHERE comicID > '$comicID' ORDER BY comicID ASC LIMIT 1 )Code: Select all
$query2='UNION( SELECT comicID FROM Comic WHERE comicID > '$comicID' ORDER BY comicID ASC LIMIT 1 )';
$result2=mysql_query($query2);Code: Select all
elseif (empty(mysql_fetch_array($result2)))
{
print('Next | '.$prevlink);
}