PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 28th, 2009, 02:32 PM
Karelll Karelll is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 1 Karelll User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 19 sec
Reputation Power: 0
php5 - Display a database thumbnail link

Hi everybody.
I have a website people can use to find a car by using scrolldown menus and selecting certain item for example mark, colour and age. to do this I use a MYSQL database and php5. To update the database I use phpmyadmin.
I have the following problem. When people make a selection the result may be multiple cars. On the result page they see a column which displays the results by: Mark of the car and a photo of the car. The save processing time I only display a thumbnail. What I would like to do is the display these thumbnails as links to the original size photo. So when someone clicks on the thumbnail displayed, the original photo pops up. I found the "Lightbox2" application on the internet and was wondering, does anybody knows how to implement this lightbox effect into my script?

my script (simplified version):
Code:
 
<?php 
    error_reporting ( E_ALL ); 
    ini_set ( 'display_errors', 1 ); 
?> 
  
<?php 
    include inlog.php 
?> 
  
<?php 
    $merken = array("audi","bmw","opel"); 
    $kleuren = array("blauw","groen","rood",); 
        if($_SERVER['REQUEST_METHOD'] == 'POST' ) { 
        $where = array(); 
        if (isset($_POST["merk"]) && in_array($_POST["merk"],$merken)) { 
            $where[] = "MERK='".$_POST["merk"]."'"; 
        } 
        if (isset($_POST["kleur"]) && in_array($_POST["kleur"],$kleuren)) { 
            $where[] = "KLEUR='".$_POST["kleur"]."'"; 
        } 
        if (isset($_POST["bouwjaar"]) && preg_match("/^(19|20)\d\d$/i", $_POST["bouwjaar"])) { 
            $where[] = "BOUWJAAR='".$_POST["bouwjaar"]."'"; 
        } 
        if (count($where)==0) { 
            echo "Geen zoektermen bekend. Opdracht geannuleerd."; 
        } else { 
            $query = "select ID, MERK, KLEUR, BOUWJAAR from catalog_tabel WHERE ".implode(" AND ",$where); 
            if ($result = mysql_query($query)) { 
                if (mysql_num_rows($result)<>0) { 
                    while ( $row = mysql_fetch_assoc ( $result ) ) { 
                        echo $row["MERK"]." - ".$row["KLEUR"]." - ".$row["BOUWJAAR"]."<br />"; 
                        $beschrijvingquery = "select BESCHRIJVING from beschrijving where Catalog_ID=".$row["ID"]; 
                        if ($beschrijvingresult = mysql_query($beschrijvingquery)) { 
                            if (mysql_num_rows($beschrijvingresult)<>0) { 
                                while ( $beschrijvingrow = mysql_fetch_assoc ( $beschrijvingresult ) ) { 
                                    echo $beschrijvingrow["BESCHRIJVING"]."<br />"; 
                                } 
                            } else { 
                                echo "geen beschrijving<br />"; 
                            } 
                        } 
                        $fotoquery = "select FOTO from foto where Catalog_ID=".$row["ID"]; 
                        if ($fotoresult = mysql_query($fotoquery)) { 
                            if (mysql_num_rows($fotoresult)<>0) { 
                                while ( $fotorow = mysql_fetch_assoc ( $fotoresult ) ) { 
                                    echo "<img src='".$fotorow["FOTO"]."' alt='".$row["MERK"]." - ".$row["KLEUR"]." - ".$row["BOUWJAAR"]."' /><br />"; 
                                } 
                            } else { 
                                echo "<img src='geenfoto.jpg' alt='geen foto' /><br />"; 
                            } 
                        } 
                    } 
                } else { 
                    echo "Geen auto's gevonden die voldoen aan uw zoekopdracht."; 
                } 
            } 
        } 
    } 
  
?> 
<hr /> 
<form method="post" action="results.php"> 
    <select name="merk"> 
        <option selected="selected">Merk</option> 
        <option><?php echo implode("</option><option>",$merken); ?></option> 
    </select> 
    <select name="kleur"> 
        <option selected="selected">Kleur</option> 
        <option><?php echo implode("</option><option>",$kleuren); ?></option> 
    </select> 
    <select name="bouwjaar"> 
        <option selected="selected">Bouwjaar</option> 
        <option>1990</option> 
        <option>1991</option> 
        <option>1992</option> 
    </select> 
    <input type="submit" value="zoeken" /> 
</form> 



I also found the following code on the internet thats should display thumbnails as links but I also do not know how to implement this code into my own script to make it work.

Code:
 
query.php 
<?php 
session_start(); 
?> 
<html> 
<?php 
  
// connect to database 
// the database has fields: thumbs, reference, and description 
$db = mysql_connect("host","name","password"); 
mysql_select_db("database",$db) or die ('Unable to connect to database'); 
$q="SELECT * FROM table"; 
$result = mysql_query( $q, $db ) 
or die(" - Failed More Information:<br><pre>$q</pre><br>Error: " . mysql_error()); 
//if result carry on 
$num_rows = mysql_num_rows($result); 
if ($myrow = mysql_fetch_array($result)) { 
  
//specify thumbnail folder 
$tn='<img src=http://your_web_site/thumbs/'; 
  
// specify target for link 
// in this case it's to retrieve more info based on the thumbnail 
$web='http://your_web_site/detail/index.php?name='; 
  
echo "<br>Listed below<BR><br>"; 
echo "<table border=1>\n"; 
echo "<tr><td><b>Reference:</b></td><td>Text:</td><td>Thumb:</td></tr>\n"; 
do { 
  
// 3 columns in this example 
printf("<tr><td>%s</td><td>%s</td><td><a href=$web%s>$tn%s.jpg></a></td></tr>\n", 
  
//display reference, description and thumb database info in this example 
// the last 2 combine into a link with a reference to carry 
// just one column, thumb alone, would be 
// printf("<tr><td><a href=$web%s>$tn%s.jpg></a></td></tr>\n", 
// $myrow["reference"], $myrow["thumb"]); 
  
$myrow["reference"], $myrow["description"],$myrow["reference"], $myrow["thumb"]); 
  
} while ($myrow = mysql_fetch_array($result)); 
echo "</table>\n"; 
  
} else { 
echo "<font face=verdana,arial,helvetica size=2 color=blue>Sorry -- the records appear to be unavailable</font>:<br>Has there been a typo? Try again?"; 
} 
mysql_free_result($result); 
mysql_close($db); 
?></html> 
________________________________________ 
/detail/index.php 
<?PHP 
session_start(); 
?> 
<html> 
<?php 
$ref="$name"; 
if (empty($ref)) { 
echo "Oooops, lost the reference"; 
// and exit 
exit; 
} 
//do a database query on that reference 
$query = "SELECT * FROM db_table WHERE reference='$ref'"; 
  
?> 
</html> 



I hope you can help me

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php5 - Display a database thumbnail link


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek