View Full Version : alignment

08-09-2005, 11:11 AM
i dont know if this should go in php or html..but whatever

heres the deal..

i have a form where users input their name and can upload a pic from their HD to the server. ok, good, got that part done


the trouble im having is displaying that stuff. I need to set it up so it looks like this




whichever is easier to do acording to the following....problems you could say

the user inputs their name, which is then stored into a text file. they are then given an option to upload an image. if they dont, a default one is used.

so somehow using tables and rows maybe, i need to display the images with their corrisponding names. heres the php for the output

$filename = "os/thenames.txt";
$handle = fopen($filename, "r"); //opens file
$contents = fread($handle, filesize($filename)); //stores file content in $contents
fclose($handle); //closes file
print "$contents"; //prints content

$dirName = "os"; //opens directory
$dp = opendir($dirName);

while ($currentFile !== false){
$currentFile = readdir($dp);
$theFiles[] = $currentFile;

$imageFiles = preg_grep("/jpg$/", $theFiles); //grabs jpg files

foreach ($imageFiles as $currentFile){ //prints images
print "<img src='http://www.domain.com/os/$currentFile' width='150' border='1'>";

if i dont do anything to the formating, it displays like this:


now does anyone have any ideas how i can change this? please ask any questions if you dont understand, im usually not very good at explaining things...but ive been working on this since 3am and its now 5 with no results

this whole script in general has taken me about 8 hours...(its the first big script ive writtin and i suck at php 9not to mention im anal about every detail)) any help....id be eternally grateful

08-09-2005, 11:27 AM
Use a delimiter, eg pipeline to store data, then when you show the data again explode it on the pipeline and do a foreach for the array? And how do you store wich user has wich picture?

08-09-2005, 11:31 AM
well first of all, i have no idea what you just said :confused:

and second, its basically just based on the first name in the text file prints, then the first image prints, so they just line up

(but now that i think of it, its not very efficient because the default image (for users who dont upload an image) is saved as (for example) 4.jpg and 9.jpg, etc.)

08-09-2005, 01:02 PM
omg...all i gotta do is explode it into an array........im retarted