public or private?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cindreta
Forum Newbie
Posts: 4
Joined: Thu Sep 21, 2006 12:04 pm

public or private?

Post by cindreta »

Hi,yes i got a question well how can i do this.. i got a upload form for images right and now i would like to add a choiche for user before the uload that they can chosse weater their picture will be private or public. So basicly they upload in the same directory but one with private and one with public option. I really would need hel with this cos i cant figure it out all by myself. Then what i would like to do is to get all images from the public database and display them. Thank you...very much i know maybe i asked too much but i know u guys will figure it out.

Im thinking somthing like this if make public is checked then the script stores that picture with value 1 in the database if not then 0... so please help me
mahendran
Forum Newbie
Posts: 3
Joined: Fri Sep 15, 2006 1:03 pm

Post by mahendran »

Hi cindreta,

Ya you have the answer for your question in your message. If you want to store the picture with public and private option then you will store the database a status value like o for public and 1 for private in addition with image .
This is basic thing. I think I told nearly correct answer to you.
Bye..
cindreta
Forum Newbie
Posts: 4
Joined: Thu Sep 21, 2006 12:04 pm

Post by cindreta »

thank you very much now only the problem is how to pull this out, so if somebody knows can you post a php code here and everything cos that is what i need, so please thank you
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

dude nobody's going to write code for you for free... we're generous, but come on man... it's your first post, and you just want somebody to whip that up for you... we'd be more than happy to help...
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Post by emmbec »

Just make a simple query from the database:

Code: Select all

<?php
	include "connect.php";
	$q="select * from images_table where status='1'";
	$a=mysql_query($q);
	while($arr=mysql_fetch_array($a)){
		echo "<img src='".$arr['image_src']."'>";							
	}
?>

images_table:
id_img | img_src | status
1 | "images/myimage.jpg" | 1

status 1 = PUBLIC
status 0 = PRIVATE


the query will only return those images who's status is equal to 1 which means its a public image
Hope this helps :wink:
Last edited by emmbec on Thu Sep 21, 2006 3:21 pm, edited 1 time in total.
cindreta
Forum Newbie
Posts: 4
Joined: Thu Sep 21, 2006 12:04 pm

Post by cindreta »

thank you now i got some problems with getting the data into the database. I made a simple checkbox and now i messed somthing up, so only if u can tell me how to get the data into the database. So for example i made if the checkbox doesn't have a tick then insert value 0 into the db and if it is checked then insert 1. So can you help me with this too cos it wont work form me thank me i really thank you...

o yeah i found out this but how to get those values into a database.

<input type="hidden" name="choice[0]" value="0" />
<input type="checkbox" name="choice[0]" value="1" />

so if it's unchend it sores 0 and if checked it sotres 1
but i can get the query to work help me
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Post by emmbec »

Read a basic PHP/MySQL tutorial, I recomend this:

http://www.w3schools.com/php/
cindreta
Forum Newbie
Posts: 4
Joined: Thu Sep 21, 2006 12:04 pm

Post by cindreta »

i got a book man php 4.1 and i could get the code to wrk anybody please and solutions
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Don't use a checkbox, use a select list with 2 choices: public (value is 1) and private (value is 0). Use that posted data as your values.

And please post some of your code. Few of us here will work for you for free. But we are more than willing to help you solve your problems.
Post Reply