Forum Moderators: coopster
What i want is one of 2 options:
1. Have the entire row be clickable that can popup the item's image calling from the mysql database.
2. Add an extra column that will have a small icon that when clicked will popup an image for that item.
I have a field for "imagePath", "imageLarge" in the database ready so i can input the url of each individual image, but just dont know the exact code to get this popup to work.
Oh yeah btw, i am using PHP
Thanks
basically, you can open a new window with href view.php?id=pic_small_2
view.php:
<?php
if(!isset($_GET['id']) ¦¦!empty($id = $_GET['id'])))
{
echo "Wrong page";
exit;
}
//here you've got id of the thumbnail (in $id)
//I would validate is somehow, eg. allow only numbers in picture name. But that depends on you.
$q = "SELECT big FROM pics WHERE small='".mysql_real_escape_string($id)."'";
//ask query, retrieve row,
$img = $result['big'];
//display it
echo "<img src=\"$img\">";
?>
I think that would be quite what you want.
PS. You can check existing galleries scripts, eg on hotscripts
Regards
Michal
Actually some the things im not so sure of are:
1. "view.php?id=pic_small_2"
- (pic_small_2) Is this something that i change myself for every individual link, or can it be automatic from the databse?
2. [small='".mysql_real_escape_string($id)."'";]
- what is .mysql_real_escape_string? I dont understand what to put there.
But i did find a perfect of example of what i need, but they are in ASP:
<snipped urls>
On the first link you can see a thumbnail image that im sure is being called from the database and it links to the product detail page. I dont need it to link to a page, but just popup the large image.
OR
#2 is more of what i am looking for. As you see its a slimmer table with a "pic" icon on the far right which popups the large image. Would be even more perfect if there is a way to have the popup link on the entire row than just a small icon.
help?
Thanks
[edited by: coopster at 4:46 pm (utc) on Nov. 2, 2006]
[edit reason] sorry, no urls (TOS [webmasterworld.com]) [/edit]
<table width="100%" border="0" cellpadding="5" cellspacing="2" class="TableContent" onmouseover="changeto(event,'#FFF887')" onmouseout="changeback(event,'#FFFFFF')">
<tr>
<td width="15%" class="TableHeader">TNT ITEM # </td>
<td width="57%" class="TableHeader">DESCRIPTION</td>
<td class="TableHeader">UPC # </td>
</tr>
<?php do {?>
<tr bgcolor="#FFFFFF">
<td><?php echo $row_littletree['itemNumber'];?></td>
<td><?php echo $row_littletree['name'];?></td>
<td><?php echo $row_littletree['UPC'];?></td>
</tr>
<?php } while ($row_littletree = mysql_fetch_assoc($littletree));?>
</table>
<tr onclick="window.location.href='http://www.example.com';"><td>...</td></tr>
if it doesn't work put the onclick into every <td
2.
pic_small_2 is a value from db from sell thumbnail - it is populated from db.
3.
[url=www.php.net/mysql_real_escape_string]mysql_real_escape_string[/url] is a function that escapes all data passed to database for security issues.
Let's imagine that you run a query:
$id = $_GET['id'];
SELECT * FROM `table` WHERE id = '$id'; //should return 1 row
let's imagine that $id is:
1' OR id > '0
Then you have got a query:
SELECT * FROM `table` WHERE id = '1' OR id > '0'; // returns all rows
not exactly what you expected - and possibly a security breach.
However if you do
$id = mysql_real_escape_string($_GET['id']);
SELECT * FROM `table` WHERE id = '$id'; // returns all rows or none.
Hope this answers all your questions
Michal
For further information don't hesitate to go to the documentation: mysql_real_escape_string [us2.php.net]
;)
Hopefully this will clear it all up:
Basically all i want is to use that <TR onClick....>
And in the href of that i need the code that will call the image URL that i inserted in the database for each item.
For ex: I have these fields in my DB table:
itemNumber ¦ Description ¦ UPC ¦ imageLarge
04-166 ¦ some item ¦ 0800880 ¦ http: //www.mywebsite.com/images/myfile.jpg
I need to find the correct way to do this (if possible):
<TR onclick="window.location.href='<?php imageLarge?>';">
The "imageLarge" is where i need some special php code that will call my DB,then Table,then FIELD.
The way my db is setup:
tnt_items(db) - air_fresheners(table) - imageLarge (field)
The TR link is not mandatory, if i can do this with just an href on a small icon, that will work too.
Thanks