Page 1 of 1

public or private?

Posted: Thu Sep 21, 2006 12:05 pm
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

Posted: Thu Sep 21, 2006 12:33 pm
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..

Posted: Thu Sep 21, 2006 12:51 pm
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

Posted: Thu Sep 21, 2006 12:57 pm
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...

Posted: Thu Sep 21, 2006 1:20 pm
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:

Posted: Thu Sep 21, 2006 1:59 pm
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

Posted: Thu Sep 21, 2006 3:27 pm
by emmbec
Read a basic PHP/MySQL tutorial, I recomend this:

http://www.w3schools.com/php/

Posted: Fri Sep 22, 2006 5:50 pm
by cindreta
i got a book man php 4.1 and i could get the code to wrk anybody please and solutions

Posted: Fri Sep 22, 2006 6:14 pm
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.