update/requery db

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have setup a table with 1 row and 2 columns.In the 1st, I have a
iframe that displays tons thumbnails of images.  In the next I have an
image (enlarged).  When the user selects a thumbnail it displays the
enlarged image in the 2nd column.  This work quite nicely.

Where I need some help is with the fact that each image has an entry
(description in a database table).  How can I display the entry when
the image is updated.  The image gets updated using javascript but the
page itself is php (as is the rest of the site).  I do not want to
reload the page everytime (long and waste of badnwidth).

Thank you for your guidance,


Re: update/requery db

Quoted text here. Click to load it

One way is to have an array of the info built with an entry for each of the  
thumbnails.  In the second column have the info for that array entry appear  
along with the enlarged image.  

Re: update/requery db


I had this in the back of my head, but do not know how to approach
it.  How can you build an array in memory an change the text
accordingly.  Any chance you could give an example?!

Thank you,


Quoted text here. Click to load it

Re: update/requery db

Quoted text here. Click to load it

Show us your code for that page.  It would make things easier for people to  
help.  Specifically, exactly what code are you using to refresh the enlarged  
image area?

In **general**, one way to build the array (put in your appropiate error  
checking, of course) is:

$res = $mysql_query("the_query_string", the_db_handle);
$numElementInArray = mysql_num_rows($res);
$theArray = array();
for ($i=0; $i<$numElementInArray; $i++) {
    $row = mysql_fetch_array($res);
    $theArray[$i] = $row['identifier'];

Then in the appropriate field in the html area you might have something  
<p><?php echo $theArray[$i]; ?></p>

where, of course, $i corresponds to the index of the particular thumbnail  
selected (its value).

More or less, this is the kind of thing you would be doing.

Re: update/requery db


Below is what I have so far.  Near the very end I placed a comment
where I am aiming to make the description appear.  I am wishing it to
cycle as the images do.  So dynamic image and description.

Database info
db name: images
db user: webuser
db pwd: 1az2301
db tbl: images

In the table there are 2 fields of interest: filename which is also
the src used for the thumbnail and desc which is the description for
that image.

Thank you once again for all your help!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
<html xmlns="http://www.w3.org/1999/xhtml ">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>

<script type="text/javascript">
    function updateimg($elename){

<table width="95%" border="1" cellspacing="0" cellpadding="0">
    <td width="200px" align="center">

<script type="text/javascript">

    * Scrollable content script II- © Dynamic Drive
    * Visit http://www.dynamicdrive.com/ for full source code
    * This notice must stay intact for use


    //specify speed of scroll (greater=faster)
    var speed=5

    if (iens6){
    document.write('<div id="container" style="position:relative;width:
175px;height:160px;border:1px solid black;overflow:hidden">')
    document.write('<div id="content" style="position:absolute;width:

<ilayer name="nscontainer" width=175 height=160 clip="0,0,175,160">
<layer name="nscontent" width=175 height=160 visibility=hidden>

<img src="../images/navbar_r1_c1.gif" name="navbar_r1_c1"
onclick="updateimg(this.name)"><br/><img src="../images/
navbar_r1_c2.gif" name="navbar_r1_c2"
onclick="updateimg(this.name)"><br/><img src="../images/
navbar_r1_c4.gif" name="navbar_r1_c4" onclick="updateimg(this.name)">


<script language="JavaScript1.2">
    if (iens6)

<table width="175px"><td><p align="right">
<a href="#" onMouseover="moveup()"
onMouseout="clearTimeout(moveupvar)"><img src="../images/up.gif"
border=0></a>  <a href="#" onMouseover="movedown()"
onMouseout="clearTimeout(movedownvar)"><img src="../images/down.gif"

<script language="JavaScript1.2">
    if (iens6){
    var crossobj=document.getElementById?
document.getElementById("content") : document.all.content
    var contentheight=crossobj.offsetHeight
    else if (ns4){
    var crossobj=document.nscontainer.document.nscontent
    var contentheight=crossobj.clip.height

    function movedown(){
    if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
    else if (ns4&&crossobj.top>=(contentheight*(-1)+100))

    function moveup(){
    if (iens6&&parseInt(crossobj.style.top)<=0)
    else if (ns4&&crossobj.top<=0)


    function getcontent_height(){
    if (iens6)
    else if (ns4)
    <img id="preview" src=""/><br/>

    <!-- This is where I would like to be able to cycle through the
description as the image selection changes -->


Re: update/requery db

I found a method, maybe not the best, but it is functional.  I simply
generate the page while adding a 2nd variable to the onclick event for
each image where I place the description.  Then mod the onclick event
to populate the innerHtml for the element.

Only issue is the 2nd variable can be up to 255 chrs. If you have
another method, I am all ears!

Thank you,

Site Timeline