VBGamer |
|||||||||||||||||||||||||||
RE: Maybe I'm dumb but... Adam Hoult (1 reply, 0 views) (2000-May-8) Uhuh,
Well php3 is not strictly a database programming language, it merely offers easy access to databases such as mysql / msql etc as well as all the other cool stuff. Basically, imagine having an if statement half way through an href tag, and be able to choose what goes in the middle, well thats basically what it allows you to do. Basically everytime someone accesses a php script on your server, an html file is dynamically generated on the server and sent to you. So you get your own personal copy of that html file =) Here is a small example of the code used to read the "News Items" section (on the left hand menu of the main page) so you can see it in action. You will have to excuse the formatting, it doesn't work on the message board =)
<!------- Current News List of 20 ------->
<?
//Here is where we do the news just in section, based up
//data stored in the NEWSMAIN table.
// Find Last ID number
if ($action!="archiveview"){
$result = mysql_query("SELECT * FROM newsmain ORDER BY id DESC");
$myrow = mysql_fetch_array($result);
$id=$myrow["id"];
$startid=$id;
}else{
$id=$startid;
}
$i = 0;
while($id!=0 && $i<20) {
$result = mysql_query("SELECT * FROM newsmain WHERE id=$id");
if (mysql_num_rows($result)!=0){
$myrow = mysql_fetch_array($result);
if($myrow["linksection"]!="inhouse"){
?>
<a href="#<?echo($myrow["linkto"]);?>"><?echo(stripslashes($myrow["linksubject"]));?></a> <br>
<?
$i++;
}
}
$id--;
}
?>
<!------- End Of Current News List ------->
|