astralaaron Posted December 5, 2007 Share Posted December 5, 2007 can someone tell me how to write this out to loop through images? <?php $name = $_GET['name']; //holds the gallery namemysql_connect("localhost","root","astralaaron")or die("connection error");mysql_select_db("galleries")or die("database 1 error");$sql = "SELECT * FROM $name ORDER BY id DESC";$result = mysql_query($sql)or die("no sql result");?><html><body><table width="100%" height="100%" border="1"><tr><td><a href="main.php">click</a></td></tr><?php while ($rep = mysql_fetch_array($result)) { ?><tr><td><?php echo "<IMG SRC=\"container/" . $name . $rep['name']; .".jpg"> ?></td> //theres only 2 fields in the galleries table right now, just `id` and `name`</tr><?php } ?></table</body></html> I don't know how to use the variables in the echo ... Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2007 Share Posted December 5, 2007 You're escaping (\) some quotes that don't need it:<?php echo "<IMG SRC=\"container/" . $name . $rep['name'] . "\">"; ?> Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 You're escaping (\) some quotes that don't need it:<?php echo "<IMG SRC=\"container/" . $name . $rep['name'] . "\">"; ?>thanks, hey how do I write the .jpg in there, forgot that Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2007 Share Posted December 5, 2007 Well, you can put it like this:- Strings are marked in green- I added ".jpg" in red<?php echo "<IMG SRC=\"container/" . $name . $rep['name'] . ".jpg\">"; ?>The output would look something like this:<IMG SRC="container/filename.jpg"> Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 Well, you can put it like this:- Strings are marked in green- I added ".jpg" in red<?php echo "<IMG SRC=\"container/" . $name . $rep['name'] . ".jpg\">"; ?>The output would look something like this:<IMG SRC="container/filename.jpg">thank you Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 do you have any idea how to display them as thumbnails? where you can click on them to open original size?edit*** must I put 2 of each picture on the site? one for them resized as a thumbnail??i hope there is a much simpler way! Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2007 Share Posted December 5, 2007 Actually, that could be quite complicated...There is a simple solution, but with drawbacks: it will take just as long to load as a big image.Just echo:<?php echo "<a href=\"container/" . $name . $rep['name'] . ".jpg\"><IMG SRC=\"container/" . $name . $rep['name'] . ".jpg\" width="80"></a>"; ?>The complicated solution would be this:You create a file called image.php and use the PHP GD library to make the file an image that loads other images dynamically with a $_GET variable and shrinks them. (I could do this, but it would take a while to make the script for the file)After that you make the echo command like this:<?php echo "<a href=\"container/" . $name . $rep['name'] . ".jpg\"><IMG SRC=\"image.php?i=" . $name . $rep['name'] . "\"></a>"; ?> Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 thanks, i think for now the simple solution will have to work.I have no clue how to do the complicated solution I will have to let the person know to keep the filesizes small Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 it shows a small box 80 px, but there is no images, just little red x's Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2007 Share Posted December 5, 2007 Can you show me lines 22, 23 and 24 of your code?You most likely forgot a semicolon ( ; ) at the end of the previous line. Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 #21 <?php while ($rep = mysql_fetch_array($result)) { ?>#22 <tr>#23 <td><?php echo "<a href=\"container/" . $name . "/" . $rep['name'] . ".jpg\"><IMG SRC=\"container/" . $name . $rep['name'] . ".jpg\" width=\"80\"></a>"; ?></td>#24 </tr>#25 <?php } ?> Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 sorry I got it.. stupid mistake<?php echo "<a href=\"container/" . $name . "/" . $rep['name'] . ".jpg\"><IMG SRC=\"container/" . $name ."/". $rep['name'] . ".jpg\" width=\"80\"></a>"; ?></td> Link to comment Share on other sites More sharing options...
Ingolme Posted December 5, 2007 Share Posted December 5, 2007 I think the image should be like this:<IMG SRC=\"container/" . $name . "/" . $rep['name'] . ".jpg\" width=\"80\">EDIT: Sorry, late response Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 I think the image should be like this:<IMG SRC=\"container/" . $name . "/" . $rep['name'] . ".jpg\" width=\"80\">EDIT: Sorry, late responseno problem man thank you very much for the lesson Link to comment Share on other sites More sharing options...
justsomeguy Posted December 5, 2007 Share Posted December 5, 2007 The photo gallery that I posted for you in the other thread does image resizing. Check the add_image function inside the functions.php file to see an example. It takes the original image, resizes it if it's too big, creates a thumbnail of a specific size, and saves both of them in the database. The view_img script gets the images from the database and sends them to the browser. Link to comment Share on other sites More sharing options...
astralaaron Posted December 5, 2007 Author Share Posted December 5, 2007 The photo gallery that I posted for you in the other thread does image resizing. Check the add_image function inside the functions.php file to see an example. It takes the original image, resizes it if it's too big, creates a thumbnail of a specific size, and saves both of them in the database. The view_img script gets the images from the database and sends them to the browser.yeah i saw the option to resize, it is awsome the way you did that gallery, I am sure it is much better than the this way I am trying Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.