...

View Full Version : image displaying (through pagination)



keissfootball
08-28-2006, 06:51 PM
Hi I'm trying to get a code like this (from DB):

<a href="#" onclick="window.open('image_1.html', 'Image', 'toolbar=no, status=no, scrollbars=no, menubar=no, width=100, height=100')"><img src="images-small/image_1_small.jpg" border="0"></a>

etc ... another 50 images

I'll show the way I paginated the records from DB when I had 1 record=1 row, maybe you could give me ideas, how to change the code, to show images the same:


<?
$konekcija=mysql_connect('127.0.0.1','*','*') or die ("Error");
mysql_select_db('*',$konekcija);
$vaicajums2="select * from `info` order by `id` desc";
$rezultats=mysql_query($vaicajums2,$konekcija);

$rindas=mysql_num_rows($rezultats);

mysql_close($konekcija);

@$lpp=$_GET['lpp'];
if (empty($lpp)){
$lpp=1;}

$lappuses=$rindas/10;
$lappuses=ceil($lappuses);

for($i=0;$i<$rindas;$i++){
$rezultats2=mysql_fetch_array($rezultats);

if($i>=($lpp*10-10)AND $i<($lpp*10)){
$tests=explode(". ", $rezultats2[0]);
echo "<b>[$rezultats2[3]]</b><br>";
for ($k=0;$k<$rezultats2[1];$k++){
echo "$tests[$k]. ";
}
}
}

for($j=1;$j<=$lappuses;$j++){
if($j == $lpp){
echo "<b><a href=\"?lpp=$j\">$j</a></b> ";
} else {
echo "<a href=\"?lpp=$j\">$j</a> ";
}
}
echo '<br><h1><a href="logout.php">Logout</a></h1><br>';
}
?>

The problem is that with this code, it took the records from every row - like this 1 row - 1 record, but now I have all images in one row. Can you help me? I don't know how can I count how many images I have, if all my code in DB is like this:


<a href="#" onclick="window.open('image_1.html', 'Image', 'toolbar=no, status=no, scrollbars=no, menubar=no, width=100, height=100')"><img src="images-small/image_1_small.jpg" border="0"></a>

<a href="#" onclick="window.open('image_2.html', 'Image', 'toolbar=no, status=no, scrollbars=no, menubar=no, width=100, height=100')"><img src="images-small/image_2_small.jpg" border="0"></a>

etc

keissfootball
08-29-2006, 08:29 AM
Does substr_count function read data from mysql too. It should be, I think. But something's wrong. Take a look. It just gives me 0 when I print out $images.


// logging to DB...
$vaicajums2="select * from `section2` where `section`= 'photo2006'";
$result=mysql_query($vaicajums2,$konekcija);

$images = substr_count($result, "</a>");
echo "$images";

mysql_close($konekcija);

@$lpp=$_GET['lpp'];
if (empty($lpp)){
$lpp=1;}

$lappuses=$images/10;
$lappuses=ceil($lappuses);

for($i=0;$i<$images;$i++){
$result2=mysql_fetch_array($result);

if($i>=($lpp*10-10)AND $i<($lpp*10)){
$test=explode("</a> ", $result2[1]);
echo "$result2[1]<br>";
for ($k=0;$k<$result2[1];$k++){
echo "$test[$k]. ";
}
}
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum