FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP question about passing variables (noob)





oly0015
Bit of a question about passing variables in PHP, I know this is simple but I figured it would a nice start. I've already gotten this to work but I am just curious about the correct way to do this operation. It's not hosted online otherwise I would have put in a link.

I've got a database that has these fields:

Name, Birthday, Gender, Bio, and Picture

Now the trick is I have a php driven page that hosts a gallery with the pictures in thumbnail form with the CSS set on the width of the page to 100%. The page is setup so that if it gets a value it shrinks this to about 300px and opens up a second column floated to the right. This contains the variable for the filename which can pull up the data via mysql getting the entire profile.

What I am curious about is to do this I passed the variable by link from a picture to the address by ".php?picture=oly0015.jpg". Would this be a correct way to do this in PHP or is there a better proper form for an operation that is simple like this? I know this works but I'd like to learn the proper way of formatting the code in PHP since I just started learning this a couple days ago.
badai
that's one of the correct way.

u can get the value from the other php by using this:

$var = $_POST['picture'];
rvec
one way would be to give every image an id, put that in the database and add the filename to that table. That way you can easily add support for stuff like comments or albums later on. The user table would then only have the image id in it.

An url would than look like images.php?image=3225 which I would rewrite to images/3225 with mod_rewrite.

One table would be
UserID, Name, Birthday, Gender, Bio, and PictureID

Another
PictureID, Path, Uploader(UserID) (if other users can choose an image from already uploaded images) and Created date

and another
PictureID, Comment, UserID
oly0015
rvec wrote:
one way would be to give every image an id, put that in the database and add the filename to that table. That way you can easily add support for stuff like comments or albums later on. The user table would then only have the image id in it.

An url would than look like images.php?image=3225 which I would rewrite to images/3225 with mod_rewrite.

One table would be
UserID, Name, Birthday, Gender, Bio, and PictureID

Another
PictureID, Path, Uploader(UserID) (if other users can choose an image from already uploaded images) and Created date

and another
PictureID, Comment, UserID


Thanks for the help

I actually already thought of something similar to that for what I've made already. Since I have control of all the filenames I just set the ID to the actual picture filename. That way when I get the filename i can go thumbnails/oly00151.jpg and images/oly0015.jpg automatically and then set that for the id on another table also for comments. So if your saying the same thing I guess this is the right way to go then for this project.
Related topics
File upload with PHP, Build an upload database for your site
PHP Validation Class
php question
JSP and PHP Question
Latest PHP install may cause phpBB to return errors...
PHP Question
PHP Question
PHP Includes and Variables?
a grouping question?
PHP question
PHP question, $_SESSION[] gets changes to by $_POST var
PHP Question - Solved
A quick PHP Question! You know the answer! Answer ASAP .
MySQL and PHP Question
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.