HighDots Forums  

the database says 15 records but only 14 are displayed

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss the database says 15 records but only 14 are displayed in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Derek @ Bl;ueyonder
 
Posts: n/a

Default the database says 15 records but only 14 are displayed - 09-26-2008 , 05:02 AM






Hi All

Just wondered if some one could given me some help please. I have been
looking at this for some time and I can not see the solutions.

I have a web page, a test version is at
http://www,zitech.co.uk/nslc.test10.php , which is supposed to show a number
of thumbnails links to which have been found in a database table.

My test program shows that there are 15 records found that match but only 14
thumbnails are shown, the first record in the database is the one that is
missing.

It would appear that by the time the program gets to the bit of the script
that sets out the thumbnails a pointer to the first record has already been
moved to the second record, hence why it is not displayed in the thumbnails.

I have used the command $gotofirstRow = mysql_data_seek($result4, 1); to try
and move the pointer back to the beginning of the records found without
success. It is the first time I have needed to use this command so I may be
doing something wrong here.

I have pasted the code in below ( sorry it has now been hacked around a fair
bit ) so you can see what I can see. As you will see a lot of the code is
actually echos to try and debug this.

Any assistance would be appreciated.

<script type="text/javascript">

function doIt(obj){
document.getElementById("bigpic").src=obj.src
}

</script>
<?php
include 'opendb.php';

//pass the value sent from the listallmemories page into whichmemory
//$memoryno = $_POST["memoryno"];
$memoryno = 1;


$sqlstring= "select * from mems2 where memoryno = $memoryno";
$result=mysql_query($sqlstring) or die('could not find $sqlstring');
$myrow=mysql_fetch_row($result);


// This is the title
echo "Memory No ";
echo $myrow[1];
echo " - ";
echo $myrow[2] . " associated pictures";



?>


<p>
<?php

echo $myrow[3];
include 'closedb.php';
?>

</p>




<?php


include 'opendb.php';


//************************************************** **************************
// count the number of records so that the dimensions of the table can be
calc'd
//************************************************** *****************************

$query3="SELECT * FROM photogallery where (memoryno = '$memoryno') and
( ass_picture_path <> '') order by memoryno";
$result3 = mysql_query($query3);

$myrow=mysql_fetch_row($result3);



// Calculate how many rows in a 5 column table we require
$howmanyrecords = mysql_num_rows($result3);
$howmanyrows = $howmanyrecords / 5;

echo " how many records found = " . $howmanyrecords;


if(!filter_var($howmanyrows, FILTER_VALIDATE_INT))
{
$howmanyrows = floor($howmanyrows);
$howmanyrows ++ ;
}






$rows = 1 ;
$recordsfound = $howmanyrecords;
$newrownow = 1;

include 'closedb.php';
include 'opendb.php';

$query4="SELECT * FROM photogallery where (memoryno = '$memoryno') and
( ass_picture_path <> '')";
$result4 = mysql_query($query4);
$myrow=mysql_fetch_row($result4);

if ($recordsfound > 0)
{


//************************************************** ***
// Calculate if we need to resize the image
//************************************************** ***

//$mypic = getimagesize("images2/$myrow[48]");

//$wide = $mypic[0];
//$high = $mypic[1];

//echo "pic name = " . $myrow[48];
//echo "<br>";
//echo "wide = " . $wide;
//echo "<br>";
//echo "high = " . $high;
//$newwide = 426;
//$newhigh = 280;

//if ($mypic[0] > 426 or $mypic[1] > 280)
//{
//if ($mypic[0] > $mypic[1] )
//{
//echo "image is too wide";
//$divby = $mypic[0] / 426;
//echo "<br>";
//echo " div wide " . $divwide;
//$newwide = $mypic[0] / $divby;
//$newhigh = $mypic[1] / $divby;
//}

//else if ($mypic[0] < $mypic[1] )
//{
//echo "image is too high";
//$divhigh = $mypic[1] / 480;
//$divby = $mypic[1] / 280;
//echo "<br>";
//echo " div high " . $divhigh;
//$newwide = $mypic[0] / $divby;
//$newhigh = $mypic[1] / $divby;
//}


//}



//************************************************** ************************************
// Table for the Big Picture
//************************************************** ************************************
echo "<table width='426' height='280' border='0' align='center' >";
echo "<tr>";
echo "<center><img id='bigpic' src='images2/" . $myrow[48] . "'
width='426px' height='280px' ></center>";
//echo"<td><div align='center'>Hello</div></td>";
echo"</tr>";
echo "</table>";

echo "<br><br>";


//************************************************** **********************************
// Build table for thumbnails
//************************************************** **********************************
echo "<table border='0' align='center'>";
echo "<tr>";

$gotofirstRow = mysql_data_seek($result4, 1);

//$row = mysql_fetch_row($result4);

while ($myrow=mysql_fetch_row($result4))
{

echo "<br>";
echo "picture name in loop = " . $myrow[48];
if ($newrownow == 6)
{
echo "</tr>";
echo "<tr>";
$newrownow = 1;
}

echo" <td width='120' height='110'><div align='center'><img
src='images2/" . $myrow[48] . "' alt='". $myrow[3] ."' title = '".
$myrow[3] ."'width='100px' height='100px' onclick='doIt(this)'></td>";

$rows ++ ;
$newrownow ++;
}
//}

}
echo "</tr>";
echo "</table>";



?>
<p>&nbsp; </p>




Reply With Quote
  #2  
Old   
Derek @ Bl;ueyonder
 
Posts: n/a

Default Re: the database says 15 records but only 14 are displayed - 09-26-2008 , 05:12 AM







Isn't it always the way, look for ages, post a question and then spot the
problem immediately.

Problem solved and the correct number of items are now displayed.

Many thanks

Derek




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.