OK, I have never ever coded in php or used mysql before but I went out and gota book and did a little fiddling about and I came up with this.
its only half here, I dont know how to do some of the stuff I want to accomplish and I thought I'd be able to get some help from you guys! Basically I want to make a navigation tool yo go through an archive of online comics. I've created a database containing the comic numbers names and I've also added a 'title' that I would like to stick in my header bar.
ok so my databe has id (the comic number) the comic_name is the name of the file (geniously starting at 00001 and working its way up sequentially) and the header is just a varchar variable with 256 characters.
This basically will load up the latest comic and set up use for the nav buttons
here's is my sketchy code
<?
$conn = mysql_connect("server name" , " " , " ");
$connect_db = mysql_select_db("comic database", $conn);
$sql = "SELECT MAX('table name'.'id') FROM 'table name';"
$last_comic = mysql_query($sql,$conn);
$comic = $last_comic
if($comic = 1){
$previous_comic = 1;
} else{
$previous_comic = $comic - 1;
}
if($comic = $last_comic){
$next_comic = $comic;
} else {
$next_comic = $comic + 1;
}
?>
Basically this will set up variables for the most recent comic, the curent comic, the previous comic and the next comic.
To actually USE th comic number (aka the id number from the database)
<?
$sql = "SELECT 'table name'.* FROM 'table name'
WHERE 'table name'.'id' = '$comic'
$issue = mysql_query($sql, $conn);
?>
That will create a variable array thing called $issue which I would them implement where
$issue[0] is the id number/$comic value
$issue[1] is the sequential 5 digit comic/blog name (00001.gif and 00001.txt relatively
$issue[2] is the name of the comic I wish to place in the title in the head of the html document
NOW...here is what I need help with.
A) now that I have variables relating to previous next last (and obviously first would be $comic = 1) how do I use this information to make html links to these comics? I have buttons all draw out and all that jazz, but I'm not sure what to type for the link...would it just be
www.mysite.com/filename.php?comic=$next_comic
or would it be more complicated than that?
where do I need to place my php script so that the variable $issue[2] (what I want to place as the title) can actualyl be used in the head portion of the html document? every example in my php book places the connection/query in the body of the html doc but wouldnt that be to late to them put something in the head? clarification or instructions aroudn this would be nice, otherwise it'll jsut be a feature I'll drop or manipulate to lsomething that works.
THANKS!!! I'll continue updating this thread with any other problems that arrise as I build my site.
nEmo