attila2452 Posted July 28, 2009 Share Posted July 28, 2009 so i had a friend in school last semester that started to teach me PHP and he used an example for my website with an image gallery. this is the code that he used. <?php$dbhost = "mysql6.000webhost.com"; $dbuser = "a1066179_Attila";$dbpass = "NOT FOR YOU TO KNOW";$dbname = "a1066179_user";$dbconn = @mysql_connect($dbhost,$dbuser,$dbpass) or die (mysql_error());$dbselect = @mysql_select_db($dbname);mysql_query("CREATE TABLE `images`");if(!$dbconn){ die("Sorry, the page is currently offline");}elseif(($dbconn)&&($dbselect)){ ?><html><head><link href="style.css" rel="stylesheet" type="text/css" /><style type="text/css">div.img{ margin: 4px; border: 1px inset #000000; height: auto; width: auto; float: left; text-align: center;} div.img img{ display: inline; margin: 3px; border: 1px ridge #000000;}div.img a:hover img {border: 1px ridge #979797;}div.desc{ text-align: center; font-weight: normal; width: 120px; margin: 2px;}</style></head><body><center><a href="?page=music"><img src="/images/music.png" border="0" /></a><a href="?page=images"><img src="/images/photos_hov.png" border="0" /></a><a href="?page=albums"><img src="/images/albums.png" border="0" /></a><a href="?page=links"><img src="/images/links.png" border="0" /></a></center><center><table border="0"><tr><td><font color="000000"><?phpif((!isset($page))||($page="")){ $page =1; } if($page < 1){ $page = 1; } if($page > lastpage){ $page = $lastpage; } $page = $_GET['page']; $limit = 10; $sql = mysql_query("SELECT `id`,`file` FROM `images`"); $numrows = mysql_num_rows($sql); $lastpage = ceil($numrows/$page); $max = 'limit ' .($page - 1) * $numrows .',' .$numrows; die(mysql_error()); $sql2 = mysql_query("SELECT `id`,`file` FROM `images` $max") or die(mysql_error()); while($row=mysql_fetch_object($sql2)){ print $row['file']; /* print'<div class="img"> <a href="?page=viewℑ=images/Orange.jpg"><img src="/images/thumb/Orange_thumb.png" alt="" width="110" height="90" /></a> <div class="desc">I\'m Orange!</div></div>';*/ }?></td></tr></table><center><?phpfunction writePage($page){echo $page . "";}echo "Images ";writePage("1 - 15");?><table><th colspan="2">Pages<br></th><tr><td><b><h3><font color="666666">1</font></h3></b> </td><td><a href="?page=images2"><h3>2</h3></a></td></tr></table></center></center></body></html><?php } ?> (ps i hid the pass just for now)I still don't know what to do with this. i don't know how to use the database and i can't follow this. can someone please help me out.? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 28, 2009 Share Posted July 28, 2009 What are you trying to do, what do you need help with? Link to comment Share on other sites More sharing options...
attila2452 Posted July 28, 2009 Author Share Posted July 28, 2009 What are you trying to do, what do you need help with?im trying to put images in a database and have PHP out put the in pages. like this+ = imgPAGE 1: + + + + + + + + +PAGE 2: + + + + + + + + +PAGE 3: + + + +so i want the database to handle the images. with if statements. without having to do the entire thing in html because its a lot of repetitive code..i also need help with inputting images in my database.make sense? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.