#1
Posted 8 February 2012 - 4:06 PM
Sorry I am pretty new to php and have tried playing around with some code but only get errors - I have managed to get the 'request image is not available' image to appear in the table so think im not too far off.
If anyone has managed to do this or could be off assistance would be great to hear from you!
Thanks
#2
Posted 8 February 2012 - 6:55 PM
#3
Posted 9 February 2012 - 6:11 AM
I was basically wondering how I would go around trying to implementing this - what code would I need to add to the table to get this to work?
Thanks
#4
Posted 10 February 2012 - 11:40 AM
I've modified the scripts to enable a client to upload images to his portfolio site - a mini CMS without the ecommerce side.
#5
Posted 10 February 2012 - 5:31 PM
browse-prints.php is part of the ecommerce example. You need to provide your own images, store them in a directory and set up the database which accesses the filename of the images. Ideally use the admin functions addArtist.php and addPrint.php to populate the d/b and get the files stored in the correct directory. If you work through the beginning of the chapter you'll set up the database, file structure and admin functions.
I've modified the scripts to enable a client to upload images to his portfolio site - a mini CMS without the ecommerce side.
Thanks for the help
I have set up the database and populated and currently have prints (with details) correctly displayed on browse_prints.php in the table, the links for each print also work and take me through to view_prints.php with the image displayed.
What I wanted to know was how to get this image to also appear in the table of prints on the browse_prints page.
Does anyone have a solution for this - I keep getting errors
#6
Posted 10 February 2012 - 8:32 PM
"I ... currently have prints (with details) correctly displayed on browse_prints.php in the table, [but] ... I wanted to know how to get this image to also appear in the table of prints on the browse_prints page."
What do you mean?
You mean you want to add additional pics to the table?
#7
Posted 11 February 2012 - 5:12 AM
Currently as followed via the tutorial in the book browse_prints is not set up to display the images, how to i go about changing the php to add the image to the prints table?
#8
Posted 11 February 2012 - 2:19 PM
<?php
$page_title = 'Display the Prints';
include ('includes/header.html');
require ('includes/mysqli_connect.php');
$q= "SELECT artists.artist_id, CONCAT_WS(' ', firstname, middlename, lastname) AS artist, printname, price, description, print_id, imagename
FROM artists, prints WHERE artists.artist_id = prints.artist_id ORDER BY artists.lastname ASC, prints.printname ASC";
if (isset($_GET['aid']) && filter_var($_GET['aid'], FILTER_VALIDATE_INT, array('min_range' => 1)) ) {
$q = "SELECT artists.artist_id, CONCAT_WS(' ', firstname, middlename, lastname) AS artist, printname, price, description, print_id, imagename
FROM artists, prints WHERE artists.artist_id = prints.artist_id AND prints.artist_id={$_GET['aid']} ORDER BY prints.printname";
}
echo '<table border="0" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width="15%"><b>Artist</b></td>
<td align="left" width="25%"><b>Thumbnail</b></td>
<td align="left" width="15%"><b>Print Name</b></td>
<td align="left" width="20%"><b>Description</b></td>
<td align="right" width="5%"><b>Price</b></td>
</tr>';
$r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n <br />MySQL Error: " . mysqli_error($dbc));
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$image = $row['imagename'];
$pid = $row['print_id'];
echo "<tr><td align=\"left\"><a href=\"browsePrints.php?aid={$row['artist_id']}\">{$row['artist']}</a></td>";
if ($image = @getimagesize ("../uploads/$pid")) {
echo "<td align=\"center\"><img src=\"showPrint.php?image=$pid&name=" . urlencode($row['imagename']) . "\" $image[3] alt=\"{$row['printname']}\" />
</td>\n";
}
echo "<td align=\"left\"><a href=\"viewPrint.php?pid={$row['print_id']}\">{$row['printname']}</td>
<td align=\"left\">{$row['description']}</td>
<td align=\"right\">{$row['price']}</td>
</tr>\n";
}
echo '</table>';
mysqli_close($dbc);
include ('includes/footer.html');
?>
#9
Posted 11 February 2012 - 2:39 PM
echo "
#10
Posted 11 February 2012 - 11:00 PM
Also your first instance of creating the $image variable seems unnecessary(isn't it?), since you re-assign the variable a couple lines down anyway and never use it outside the if conditional there.
I do admire your ability to improvise, since that seams to be a large portion of programming. Trust me when I tell you I am not speaking from superiority, since you are likely a better programmer than me. Good job!!!
#11
Posted 12 February 2012 - 11:01 AM
In my previous post, the amended code didn't show up so here it is,
if ($image = @getimagesize ("../uploads/$pid")) {
echo "<td align=\"center\"><img src=\"showPrint.php?image=$pid&name=" . urlencode($row['imagename']) . "height=\"200\" width=\"200\" alt=\"{$row['printname']}\" />
</td>\n";
nothing new logically, just a height and width on the image tag to help with the display. Probably not the best way performance wise as I think all this re-sizing could slow down the page load.
#12
Posted 12 February 2012 - 6:19 PM
#13
Posted 12 February 2012 - 7:41 PM
Also tagged with one or more of these keywords: images
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide →
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition) →
Chapter 11 Header Section, Images Will Not Show On ClickStarted by AJugOrNot , 17 May 2013 |
|
|
||
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide →
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition) →
Resizing Images Without Losing Quality.Started by jabsalud , 23 Dec 2012 |
|
|
||
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide →
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition) →
Thumbnail ImagesStarted by lalarukh12 , 5 Aug 2012 |
|
|










