Arnerd Posted February 11, 2010 Share Posted February 11, 2010 Hello all im trying to make my first image gallery in php ive run into a problem i got this page wich shows the first picture out of the table pictures .... with a next button, u can go to the same page, but with the next image in the table ... if i push the button, it will look for the picture with the next id ... index field ... BUT when i delete pictures, offcourse this will not work proper anymore .... so what is the best way of solving this? putting the query into an array? can someone help me on this? and also tell me how te speak to the array? thx so much in advance Link to comment https://forums.phpfreaks.com/topic/191742-query-into-array/ Share on other sites More sharing options...
jl5501 Posted February 11, 2010 Share Posted February 11, 2010 There are many ways of doing this easily. Can you post some of your code you are using and we can provide more specific help Link to comment https://forums.phpfreaks.com/topic/191742-query-into-array/#findComment-1010625 Share on other sites More sharing options...
Arnerd Posted February 11, 2010 Author Share Posted February 11, 2010 offcourse <?php session_start(); ini_set('display_errors', 1); error_reporting(E_ALL); require_once 'db_config.php'; $naam = $_SESSION["myusername"]; $id = $_GET["id"]; if(!$_SESSION["myusername"]=$naam){ header("location:main_login.php"); } ?> <html> <body><a href="registreer.php">Registreer</a> <a href="main_login.php">Login-Pagina</a> <a href="admin.php">Admin-Pagina</a><br /> U bent ingelogd als <?php echo $naam; ?> <br /><br /> <?php $sql2="SELECT * FROM planten"; $result2=mysql_query($sql2); $count=mysql_num_rows($result2); $begin = $id-3; $einde = $id+3; while ($foto = mysql_fetch_assoc($result2)) { $picture = $foto["foto"]; $id2 = $foto["id"]; if ($id2 > $begin AND $id2 < $einde) { if ($id2 == $id) { echo ' <?php <a href="bigpic.php?id='.$id2.'"><img src="Fotos/'.$picture.'" height="45" width="75" alt="test"></a> '; } else { echo '<a href="bigpic.php?id='.$id2.'"><img src="Fotos/'.$picture.'" height="90" width="150" alt="test"></a>'; } } } if ($count == "0") { echo "Upload fotos AUB"; } $sql="SELECT * FROM planten WHERE id='$id'"; $result=mysql_query($sql); echo "<br /><br />"; $vorige = $id-1; $volgende = $id+1; if ($id >= 2) { echo '<a href="bigpic.php?id='.$vorige.'">Vorige</a>'; } if ($fotogroot = mysql_fetch_assoc($result)) { $url = $fotogroot["foto"]; echo '<img src="Fotos/'.$url.'" height="495" width="750">'; } if ($id < $count) { echo '<a href="bigpic.php?id='.$volgende.'">Volgende</a>'; } ?><br /><a href="home.php">Terug naar Home</a> </body> </html> Link to comment https://forums.phpfreaks.com/topic/191742-query-into-array/#findComment-1010627 Share on other sites More sharing options...
jl5501 Posted February 11, 2010 Share Posted February 11, 2010 Ok what you seem to be trying to do is to have the previous and next 3 images showing links. I see your problem with using a fixed counter from the passed id, so what you need to do is to devise a way of finding out what the previous 3 and next 3 ids actually are. Link to comment https://forums.phpfreaks.com/topic/191742-query-into-array/#findComment-1010638 Share on other sites More sharing options...
Arnerd Posted February 11, 2010 Author Share Posted February 11, 2010 yes i know and i think i have todo it with an array, im now reading on how to use array properly if someone knows a clean script on this, i would like to see it thx Link to comment https://forums.phpfreaks.com/topic/191742-query-into-array/#findComment-1010640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.