Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    PHP Photo Changer

    What I need help with is being able to click and change a main image with other thumbnails.

    The problem is (i think) is because the page is loading different pictures for different products and from the database it's not working with js or jqeury.

    here is the code

    ----------Main Image--------------

    <div id="image"><?php echo '<img src="pics/'.$row['pic1'].'">';?> </div>
    ------------Thumbs-------------------------------

    PHP Code:
     echo '<img src="pics/'.$row['pic2'].'">';?> <?php echo '<img  src="pics/'.$row['pic3'].'">';?> <?php echo '<img src="pics/'.$row['pic4'].'">';?><?php echo '<img src="pics/'.$row['pic5'].'">';?><?php echo '<img src="pics/'.$row['pic6'].'">';?><?php echo '<img src="pics/'.$row['pic7'].'">';?><?php echo '<img src="pics/'.$row['pic8'].'">';?><?php echo '<img src="pics/'.$row['pic9'].'">';?>
    A online live demo can be viewed if necessary.

    Any help would be much appreciated and thank you in advance
    Last edited by chris23; 08-02-2012 at 04:02 PM.

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    What does a print_r of $row produce? I have a suspicion it should be

    $row['pic3'][0]

  • Users who have thanked DrDOS for this post:

    chris23 (08-02-2012)

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    ( [0] => 36 [id] => 36 [1] => [title] => [2] => [model] => [3] => [cat_id] => [4] => tlfjldsjlkdsjsd [description] => tlfjldsjlkdsjsd [5] => [year_regletter] => [6] => [vin_number] => [7] => [type] => [8] => [axle_config] => [9] => [gross_weight] => [10] => tt [suspension] => tt [11] => [transmission] => [12] => [power_output] => [13] => [mileage] => [14] => [mot_status] => [15] => 1002092 [price] => 1002092 [16] => 36-1.jpg [pic1] => 36-1.jpg [17] => 36-2.jpg [pic2] => 36-2.jpg [18] => 36-3.jpg [pic3] => 36-3.jpg [19] => 36-4.jpg [pic4] => 36-4.jpg [20] => 36-5.jpg [pic5] => 36-5.jpg [21] => 36-6.jpg [pic6] => 36-6.jpg [22] => [pic7] => [23] => [pic8] => [24] => [pic9] => ) 
    Here is the page code

    Code:
    ]<style>
    #col-1{
    	width:450px;
    	height:450px;
    	margin-right:55px;
    	float:left;
    }
    #col-2{
    	width:450px;
    	float:left;
    	height:450px;
    }
    #col-3{
    	height:120px;
    	width:100%;
    	margin-top:165px;
    	margin-bottom:25px;
    }
    
    #col-3 img{
    	height:100px;
    	width:100px;
    	margin-right:15px;
    
    }
    
    
    
    .box img {
    	height:100px;
    	width:150px;
    }
    .box{
    	width:150px;
    	float:left;
    	background-color:#0F0;
    	margin-right:20px;
    	height:100px;
    }
    #image{
    	background-image:url(temp/img_holder.jpg);
    	height:310px;
    }
    
    #image img{
    	width:426px;
    	height:287px;
    	margin-top:8px;
    	margin-left:16px;
    
    }
    </style>
    <?php include('header.php');?>
    <?php
     $id = $_REQUEST['id'];
     $result = mysql_query("SELECT * FROM products WHERE id = '$id';") or die(mysql_error());
     $row = mysql_fetch_array( $result );
     $title=$row['title'];
    ?>
    <div id="wrapper" style="margin-top:-85px;">
    <div id="page" style="height:660px;">
    <div id="col-1">
      <h2><?php echo "{$row['title']}";?></h2>
      <div id="image"><?php echo '<img src="pics/'.$row['pic1'].'">';?>  </div>
        <br/><br/><br/>
        <h3>Further Vehicle Details</h3>
        <p style="text-align:justify; margin-top:-10px;">
        <?php echo "{$row['description']}";?>
        </p>
    </div>
    <div id="col-2">
    <img src="temp/enquire.jpg" alt=""/>
    <table width="401">
      <tr>
        <td style="border-bottom:#999 1px solid;">Model: <p style="padding:0; float:right; margin:0"><?php echo "{$row['model']}";?></p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">Year &amp; Reg Letter: <p style="padding:0; float:right; margin:0"><?php echo "{$row['year_regletter']}";?></p></td>
      </tr
      ><tr>
        <td style="border-bottom:#999 1px solid;">Axel Config: <p style="padding:0; float:right; margin:0"><?php echo "{$row['axle_config']}";?></p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">Gross Weight: <p style="padding:0; float:right; margin:0"><?php echo "{$row['gross_weight']}";?> kg</p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">Suspension: <p style="padding:0; float:right; margin:0"><?php echo "{$row['suspension']}";?></p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">Transmission: <p style="padding:0; float:right; margin:0"><?php echo "{$row['transmission']}";?></p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">Power Output: <p style="padding:0; float:right; margin:0"><?php echo "{$row['power_output']}";?> bhp</p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">Mileage: <p style="padding:0; float:right; margin:0"><?php echo "{$row['mileage']}";?> km</p></td>
      </tr>
      <tr>
       <td style="border-bottom:#999 1px solid;">MOT Status: <p style="padding:0; float:right; margin:0"><?php echo "{$row['mot_status']}";?></p></td>
      </tr>
      <tr>
      <td style="border-bottom:#999 1px solid;">Cost: <p style="padding:0; font-weight:bold; float:right; margin:0"> <?php echo "{$row['price']}";?></p></td>
      </tr>
    </table
    ></div>
    <div class="clearfix"></div>
     <br/><br/><br/>
     <div id="col-3" style="margin-top:-5px;">
    <?php echo '<img src="pics/'.$row['pic2'].'">';?> <?php echo '<img  src="pics/'.$row['pic3'].'">';?> <?php echo '<img src="pics/'.$row['pic4'].'">';?><?php echo '<img src="pics/'.$row['pic5'].'">';?><?php echo '<img src="pics/'.$row['pic6'].'">';?><?php echo '<img src="pics/'.$row['pic7'].'">';?><?php echo '<img src="pics/'.$row['pic8'].'">';?><?php echo '<img src="pics/'.$row['pic9'].'">';?>
    
    <br/>
    </div>
    </div>
    <br/>
    </div>
    
    <?php include('footer.html');?>
    Last edited by chris23; 08-02-2012 at 05:55 PM.

  • #4
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you in advance and for replying to me

  • #5
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,899
    Thanks
    15
    Thanked 226 Times in 226 Posts
    print_r($row) is what we need to see here. Could you put that in the page and edit your post to include what it yields?

  • #6
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    You should not have php opening tags right after php closing tags. I have cleaned up your code to make it easier to read, but your problem probably still exists.

    PHP Code:
    <?php

    echo '<img src="pics/'.$row['pic2'].'">';
    echo 
    '<img src="pics/'.$row['pic3'].'">';
    echo 
    '<img src="pics/'.$row['pic4'].'">';
    echo 
    '<img src="pics/'.$row['pic5'].'">';
    echo 
    '<img src="pics/'.$row['pic6'].'">';
    echo 
    '<img src="pics/'.$row['pic7'].'">';
    echo 
    '<img src="pics/'.$row['pic8'].'">';
    echo 
    '<img src="pics/'.$row['pic9'].'">';

    ?>
    Leonard Whistler


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •