Need help generating tables w/ images...
Moderator: General Moderators
Need help generating tables w/ images...
Hey, I could really use some help. What I want to do is, for instance, just say i had 20 .jpg thumbnails which have a name associated with each thats different than the filename. And I wanted to have a control page, where I could view all 20 images and click a tickbox next to the ones I wanted on the result page. So if i clicked the tickbox next to image 1,3 and 4, it would generate a webpage with tables that included only those three images in each table row, and the text associated with them. To better illustrate this i made a image, the table on the left would be a seperate control page, and the table on the right would be the generated result on a seperate page. Whats the best way to tackle this? I have browsed through the entire php manual and am now more familiar with many php concepts but still need help with how I should start coding this. Thanks

one way is to...
setup an array for the photos that are checked
Loop through your array after the POST to build the table..
setup an array for the photos that are checked
Code: Select all
print"<input type="checkbox" size=2 name="photosї{$id}]" value="{$file}">";Code: Select all
$photoarray=$_POSTї'photos'];
foreach ($photoarray as $id => $file){
//build output table rows...
}piece of cake =)
theres alot of the code to do it, but there are still some holes to fill in. basicly you build an array of the images by file name or some other means (id field in a db?), then on the second page you read all the image names or ids back out and use that to generate the table of images you selected. prolly the best way to do this would be to use a database, and key for the value of the images[] array. anywho, i hope this helps
Code: Select all
// PAGE 1
<table>
<?php
// loop to make first image table
print"\t<tr>\n";
print"\t\t<td>\n";
print"\t\t<td>Some text here</td>\n";
print"\t\t<td><img src="img_1.jpg"></td>\n";
print"\t\t<td><input type="checkbox" name="images[]" value="img_1.jpg"></td>\n";
print"\t<tr>\n";
?>
<tr>
<td colspan="3"><input type="submit" name="action" value="Submit"></td>
</tr>
</table>
// PAGE 2
<table>
<?php
foreach($images as $image){
print"\t<tr>\n";
print"\t\t<td>\n";
print"\t\t<td>Some text here</td>\n";
print"\t\t<td><img src="img_1.jpg"></td>\n";
print"\t<tr>\n";
}
?>
</table>