For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > November 2004 > Importing photo and text with PHP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Importing photo and text with PHP
Pascal Bouchard

2004-11-04, 8:55 pm

I am a beginner in PHP.
On my website, I have pages with photos thumbnails. Each thumbnail is a link
opening a html page with a larger photo and some text.
I saw on some web sites that it is possible to do the same with PHP with the
great advantage of always reusing the same html page to load different
photos and descriptive text.
Links to tutorials explaning how is it done?
Many thanks!
Pascal


---
Ce courriel est exempt de virus.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.783 / Virus Database: 529 - Release Date: 2004-10-25


Floortje

2004-11-04, 8:55 pm


"Pascal Bouchard" <forum@mitan.ca> schreef in bericht
news:W6xid.263$ab.145059@weber.videotron.net...
> I am a beginner in PHP.
> On my website, I have pages with photos thumbnails. Each thumbnail is a

link
> opening a html page with a larger photo and some text.
> I saw on some web sites that it is possible to do the same with PHP with

the
> great advantage of always reusing the same html page to load different
> photos and descriptive text.
> Links to tutorials explaning how is it done?
> Many thanks!
> Pascal
>


Create a database
pictures(id, pic, text) etc
dont forget to connect to ur database first see www.php.net

index.php
<?php
$sql = "SELECT pic,id "
. "FROM pic ";
$query = mysql_query("$sql")
or exit ("Ongeldige query " . mysql_error());
while($row = mysql_fetch_array($query))
{echo '<a href="picpage.php?pic_id='.$row[id].'"><img
src="thumbs/'.$row[pic].'"> </a>';}
?>



picpage.php
<?php
$sql = "SELECT pic,text "
. "FROM pic "
. "WHERE id =$_GET[id]";
$query = mysql_query("$sql")
or exit ("Ongeldige query " . mysql_error());

$row = mysql_fetch_array($query);

echo '<img src="'.$row[pic].'">';
echo '<p>'.$row[text].'</p>';
?>





Pascal Bouchard

2004-11-05, 3:56 pm

Many thanks, Floortje.
Now I know for sure it can be done and that I have to do my part and do some
tutorials!

Dans un message précédent, Floortje
<floortje- apestaartjexs4allpuntnl@hetminnetjehoort
.erbij> a écrit:
> "Pascal Bouchard" <forum@mitan.ca> schreef in bericht
> news:W6xid.263$ab.145059@weber.videotron.net...
>
> Create a database
> pictures(id, pic, text) etc
> dont forget to connect to ur database first see www.php.net
>
> index.php
> <?php
> $sql = "SELECT pic,id "
> . "FROM pic ";
> $query = mysql_query("$sql")
> or exit ("Ongeldige query " . mysql_error());
> while($row = mysql_fetch_array($query))
> {echo '<a href="picpage.php?pic_id='.$row[id].'"><img
> src="thumbs/'.$row[pic].'"> </a>';}
>
>
>
> picpage.php
> <?php
> $sql = "SELECT pic,text "
> . "FROM pic "
> . "WHERE id =$_GET[id]";
> $query = mysql_query("$sql")
> or exit ("Ongeldige query " . mysql_error());
>
> $row = mysql_fetch_array($query);
>
> echo '<img src="'.$row[pic].'">';
> echo '<p>'.$row[text].'</p>';



---
Ce courriel est exempt de virus.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.783 / Virus Database: 529 - Release Date: 2004-10-26


Floortje

2004-11-05, 8:55 pm


"Pascal Bouchard" <forum@mitan.ca> schreef in bericht
news:HdMid.48183$ab.598808@weber.videotron.net...
> Many thanks, Floortje.
> Now I know for sure it can be done and that I have to do my part and do

some
> tutorials!


Actually the code is allmost done. All u need to do is quickly read over
some basic PHP syntax, basic SQL and google for phpmyadmin

Floortje


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com