I have this really huge code here. I need it to be shorter because my webserver cannot handle all of it. Can anyone help me with it? I am new to this (if) and (while) statement thing. Here is what I want to happen. I want 5 pictures to be on one row, then the next five seperated by a <p> or a <br>, then I need the next five, and so on. So is there a logical way of doing this? I am new to coding and need some help. Thanks!
Here is my code.
<?php
$i=0;
$db = mysql_connect("localhost","olentang","HrcomxYp");
mysql_select_db("olentangyriver_org", $db);
$sql = "select * from general";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$ii=$i+1;
$i=$ii;
while($i<=5){
printf("<a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>6)&&($i<=10)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>11)&&($i<=15)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>16)&&($i<=20)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>21)&&($i<=25)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>26)&&($i<=30)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>31)&&($i<=35)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>34)&&($i<=40)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>39)&&($i<=45)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>46)&&($i<=50)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>49)&&($i<=55)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>54)&&($i<=60)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>59)&&($i<=65)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>64)&&($i<=70)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>69)&&($i<=75)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>76)&&($i<=80)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>81)&&($i<=85)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>86)&&($i<=90)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>91)&&($i<=95)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
while(($i>96)&&($i<=100)){
printf("<p><a href='picout.php?picid=%s'><img src='%s' height='83' width='83'>\n",$row["pic_id"],$row["pic_url"]);
}
}
?>
I told you it was long!
🙂
$zip