runnerjp Posted May 4, 2007 Share Posted May 4, 2007 hey guys... a quickie is there away i can let users upload images and then have them set as there profile picture for every 1 to see?? you know like myspace or facebook all these popular profile sites or like on here the avatars.... i say is there away obviously there is,,, i should by saying how?? lol Quote Link to comment Share on other sites More sharing options...
Caesar Posted May 4, 2007 Share Posted May 4, 2007 Extremely easy using a MySQL database. Assuming you have a users table where you store a unique identifier, you simply tie that image to the particular user. This requires only a minimal understanding of PHP/MySQL so I suggest running through some quick tutorials with working examples. I don't think giving you code would help. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 4, 2007 Author Share Posted May 4, 2007 ok doki ill have alook through Quote Link to comment Share on other sites More sharing options...
Rottingham Posted May 4, 2007 Share Posted May 4, 2007 This is done in a very easy fashion, byt I agree with Ceasar, providing code here would only hinder your learning process. I will give you an idea of how I did it. I have a fully database driven application for church directories, attendence, service information, family directories, individual profiles, etc etc. Each image is in the Images/profiles/pics/ directory, and the image file name is the person's database ID number, which is always unique, .jpg. Or, the person who's ID number is 365, their profile images is 365.jpg. When the file is uploaded, it is moved to Images/profiles/pics/365.jpg. Any time their profile page is opened, PHP checks to see if the file is available, with if(fileexists(...path/to/image)). Hope that helps a little. In cases like this, it is really unique to your style and application. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 ok i have been trying with it and i cant seem to do anything with it can some 1 please post the code up...that way i can look it it and see what it does also..i have tried Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 if it helps i have made an images table image_id directory image url displayname default_pic just need to know how i would access each users pics wiht it? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 *bump* Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 post YOUR code and explain the problem Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 <? $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "SELECT * FROM $tbl_images WHERE directory = \"$directory\" AND default_pic = \"yes\""; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); $PICSnum=mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $url = $row['url']; $image = $row['image']; } if(empty($url)) {$newurl="$imgdir";}else{$newurl="$userdir/$url";} if(empty($image))$image="pic.gif"; $showimg="/$newurl/$image"; ?> <script type="text/javascript"> function openpopup(popurl){ var winpops=window.open(popurl,"","width=610px,height=625px,resizable") } </script> <p align="center"> <a href="javascript:openpopup('showpic.php?img=<?echo $image ?>')"><IMG SRC="../../thumbs/phpThumb.php?src=<?echo $showimg ?>&w=150" border="0"></a> <? if($PICSnum > "0") { ?> <br><a href="<?echo $PHP_SELF ?>?action=pics">My Pictures >></a> <? } if($profile_id == $auth[member_id]){ echo "<br><a href=\"$userurl/upload.php\">upload picture</a>"; ?> thought summats like this but nothing appears on screen but pic.gif thats set as a default pic not the uploaded 1 from the table Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 does your database hold valid data, as you seam to be missing some code, from what i can see (without code tags) Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 image_id directory image url displayname default_pic thats what my database is holding.... basicly what i wanna do is get the image from the members id the is loged in at the present time... shouldent this do it... so i have someing like this image_id directory image url displayname default_pic 00000001 /home/runnerse/public_html/users/Admin test.jpg Admin Admin yes Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 some one must know wats to be done lol Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 as i said does your database hold valid data, as you seam to be missing some code, from what i can see (without code tags) Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 5, 2007 Author Share Posted May 5, 2007 yes it holds valid data...what have i missed out?? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 erm.. the code that uploads the file the code that sets $directory & $tbl_images & $userdir & $imgdir & $PICSnum & $profile_id & $auth the code for the page with the error (displaying nothing) aka showpic.php meah.. good luck Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.