grunger Posted February 12, 2007 Share Posted February 12, 2007 I am sure there is allot easier script that can do the same but, i am not a pro If you are then you can help me make a easier and working code <? //include header... check are you logined... xhtml design.... include "header.php"; ?> <?php $db = mysql_connect("fdb1.awardspace.com", "xxxxxx", "xxxxxx"); mysql_select_db("grunger_noob",$db); $query1 = "SELECT * FROM gallery_db WHERE id=1"; $result1 = mysql_query($query1)or die('Error, query failed. ' . mysql_error()); while($myrow1 = mysql_fetch_array($result1)) $query2 = "SELECT * FROM gallery_db WHERE id=2"; $result2 = mysql_query($query2)or die('Error, query failed. ' . mysql_error()); while($myrow2 = mysql_fetch_array($result2)) $query3 = "SELECT * FROM gallery_db WHERE id=3"; $result3 = mysql_query($query3)or die('Error, query failed. ' . mysql_error()); while($myrow3 = mysql_fetch_array($result3)) $query4 = "SELECT * FROM gallery_db WHERE id=4"; $result4 = mysql_query($query4)or die('Error, query failed. ' . mysql_error()); while($myrow4 = mysql_fetch_array($result4)) $query15 = "SELECT * FROM gallery_db WHERE id=5"; $result5 = mysql_query($query5)or die('Error, query failed. ' . mysql_error()); while($myrow5 = mysql_fetch_array($result5)) $query6 = "SELECT * FROM gallery_db WHERE id=6"; $resul6 = mysql_query($query6)or die('Error, query failed. ' . mysql_error()); while($myrow6 = mysql_fetch_array($result6)) $query7 = "SELECT * FROM gallery_db WHERE id=7"; $result7 = mysql_query($query7)or die('Error, query failed. ' . mysql_error()); while($myrow7 = mysql_fetch_array($result7)) $query8 = "SELECT * FROM gallery_db WHERE id=8"; $result8 = mysql_query($query8)or die('Error, query failed. ' . mysql_error()); while($myrow8 = mysql_fetch_array($result8)) $query9 = "SELECT * FROM gallery_db WHERE id=9"; $result9 = mysql_query($query9)or die('Error, query failed. ' . mysql_error()); while($myrow9 = mysql_fetch_array($result9)) $query10 = "SELECT * FROM gallery_db WHERE id=10"; $result10 = mysql_query($query20)or die('Error, query failed. ' . mysql_error()); while($myrow1 = mysql_fetch_array($result10)) $query11 = "SELECT * FROM gallery_db WHERE id=11"; $result11 = mysql_query($query11)or die('Error, query failed. ' . mysql_error()); while($myrow11 = mysql_fetch_array($result)) $query12 = "SELECT * FROM gallery_db WHERE id=12"; $result12 = mysql_query($query12)or die('Error, query failed. ' . mysql_error()); while($myrow1 = mysql_fetch_array($result12)) $query13 = "SELECT * FROM gallery_db WHERE id=13"; $result13 = mysql_query($query13)or die('Error, query failed. ' . mysql_error()); while($myrow13 = mysql_fetch_array($result13)) $query14 = "SELECT * FROM gallery_db WHERE id=14"; $result14 = mysql_query($query14)or die('Error, query failed. ' . mysql_error()); while($myrow14 = mysql_fetch_array($result14)) $query15 = "SELECT * FROM gallery_db WHERE id=15"; $result15 = mysql_query($query15)or die('Error, query failed. ' . mysql_error()); while($myrow15 = mysql_fetch_array($result15)) $query16 = "SELECT * FROM gallery_db WHERE id=16"; $result16 = mysql_query($query16)or die('Error, query failed. ' . mysql_error()); while($myrow16 = mysql_fetch_array($result16)) $query17 = "SELECT * FROM gallery_db WHERE id=17"; $result17 = mysql_query($query17)or die('Error, query failed. ' . mysql_error()); while($myrow17 = mysql_fetch_array($result17)) $query18 = "SELECT * FROM gallery_db WHERE id=18"; $result18 = mysql_query($query18)or die('Error, query failed. ' . mysql_error()); while($myrow18 = mysql_fetch_array($result18)) $query19 = "SELECT * FROM gallery_db WHERE id=19"; $result19 = mysql_query($query19)or die('Error, query failed. ' . mysql_error()); while($myrow19 = mysql_fetch_array($result19)) $query20 = "SELECT * FROM gallery_db WHERE id=20"; $result20 = mysql_query($query20)or die('Error, query failed. ' . mysql_error()); while($myrow20 = mysql_fetch_array($result20)) ?> <a href="<?php echo $myrow1["url"];?>" target="_blank"><img src="<?php echo $myrow1["thumb_url"];?>"></a> <a href="<?php echo $myrow2["url"];?>" target="_blank"><img src="<?php echo $myrow2["thumb_url"];?>"></a> <a href="<?php echo $myrow3["url"];?>" target="_blank"><img src="<?php echo $myrow3["thumb_url"];?>"></a> <a href="<?php echo $myrow4["url"];?>" target="_blank"><img src="<?php echo $myrow4["thumb_url"];?>"></a><br> <a href="<?php echo $myrow5["url"];?>" target="_blank"><img src="<?php echo $myrow5["thumb_url"];?>"></a> <a href="<?php echo $myrow6["url"];?>" target="_blank"><img src="<?php echo $myrow6["thumb_url"];?>"></a> <a href="<?php echo $myrow7["url"];?>" target="_blank"><img src="<?php echo $myrow7["thumb_url"];?>"></a> <a href="<?php echo $myrow8["url"];?>" target="_blank"><img src="<?php echo $myrow8["thumb_url"];?>"></a><br> <a href="<?php echo $myrow9["url"];?>" target="_blank"><img src="<?php echo $myrow9["thumb_url"];?>"></a> <a href="<?php echo $myrow10["url"];?>" target="_blank"><img src="<?php echo $myrow10["thumb_url"];?>"></a> <a href="<?php echo $myrow11["url"];?>" target="_blank"><img src="<?php echo $myrow11["thumb_url"];?>"></a> <a href="<?php echo $myrow12["url"];?>" target="_blank"><img src="<?php echo $myrow12["thumb_url"];?>"></a><br> <a href="<?php echo $myrow13["url"];?>" target="_blank"><img src="<?php echo $myrow13["thumb_url"];?>"></a> <a href="<?php echo $myrow14["url"];?>" target="_blank"><img src="<?php echo $myrow14["thumb_url"];?>"></a> <a href="<?php echo $myrow15["url"];?>" target="_blank"><img src="<?php echo $myrow15["thumb_url"];?>"></a> <a href="<?php echo $myrow16["url"];?>" target="_blank"><img src="<?php echo $myrow16["thumb_url"];?>"></a><br> <a href="<?php echo $myrow17["url"];?>" target="_blank"><img src="<?php echo $myrow17["thumb_url"];?>"></a> <a href="<?php echo $myrow18["url"];?>" target="_blank"><img src="<?php echo $myrow18["thumb_url"];?>"></a> <a href="<?php echo $myrow19["url"];?>" target="_blank"><img src="<?php echo $myrow19["thumb_url"];?>"></a> <a href="<?php echo $myrow20["url"];?>" target="_blank"><img src="<?php echo $myrow20["thumb_url"];?>"></a><br> <?php // include footer include "footer.php"; ?> I swear there are working database with id 1-20 and both header and footer is working... The errors are as simple as: Error, query failed. Query was empty And i swear as before that i have the id 1-20 As i made a little script to check it out, result: http://img144.imageshack.us/img144/427/desktopyf5.jpg As you see i have two empty fields in my db name and renderer but that should not make any problems. Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/ Share on other sites More sharing options...
paul2463 Posted February 12, 2007 Share Posted February 12, 2007 try this <?php $query1 = "SELECT * FROM gallery_db LIMIT 20"; $result1 = mysql_query($query1)or die('Error, query failed. ' . mysql_error()); $count = 1; while($myrow1 = mysql_fetch_array($result1)) { echo "<a href='.$myrow1['url'].' target='_blank'><img src='.$myrow1['thumb_url'].'></a>"; if ($count == 4) { echo "< /br>"; $count = 0; } $count++; } ?> Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182714 Share on other sites More sharing options...
ldsmike88 Posted February 12, 2007 Share Posted February 12, 2007 Holy cow. Just for future reference people generally do not like to see a HUGE script and want to go through and edit the whole thing for someone. But just to be nice: <? //include header... check are you logined... xhtml design.... include "header.php"; $db = mysql_connect("fdb1.awardspace.com", "xxxxxx", "xxxxxx"); mysql_select_db("grunger_noob",$db); $myArray = range(1, 20); foreach($myArray as $myNum){ $query = "SELECT * FROM gallery_db WHERE id=$myNum"; $result = mysql_query($query)or die('Error, query failed. ' . mysql_error()); $myrow = mysql_fetch_array($result); echo '<a href="' . $myrow["url"] . '" target="_blank"><img src="' . $myrow["thumb_url"] . '"></a>'; } //include footer include "footer.php"; ?> Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182725 Share on other sites More sharing options...
grunger Posted February 12, 2007 Author Share Posted February 12, 2007 gives error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/noobdesign.awardspace.com/viewdb_graph.php on line 14 This is line 14 echo "<a href='.$myrow1['url'].' target='_blank'><img src='.$myrow1['thumb_url'].'></a>"; That was for first answer testing second now:D Worked but dunno how to add the < /br> Every fourth image That the very important thing Is there any easy way to edit the $myArray = range(1, 20); So that if this was render.php if i wrote render.php?start=21 then it would do start at 21 and stop at 40? Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182726 Share on other sites More sharing options...
Balmung-San Posted February 12, 2007 Share Posted February 12, 2007 Somebody forgot which quotes they were using. echo "<a href='".$myrow1['url']."' target='_blank'><img src='".$myrow1['thumb_url']."'></a>"; That should work now. Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182729 Share on other sites More sharing options...
grunger Posted February 12, 2007 Author Share Posted February 12, 2007 Now both worked and the first ones got the <br> But still wants that render.php?start=21 Read the second post by me if you don't know what i mean. And i am really surprised how fast you guys answered Thanx for the help so far! Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182737 Share on other sites More sharing options...
grunger Posted February 12, 2007 Author Share Posted February 12, 2007 Took a little longer this time lol Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182766 Share on other sites More sharing options...
grunger Posted February 12, 2007 Author Share Posted February 12, 2007 bumb bumb tired off getting to 2nd page Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-182845 Share on other sites More sharing options...
grunger Posted February 13, 2007 Author Share Posted February 13, 2007 help needed Link to comment https://forums.phpfreaks.com/topic/38174-help-with-a-simple-script/#findComment-183570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.