Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 04-03-2007, 08:41 PM
nster's Avatar
Junior Member
 
Join Date: 11-06-06
Posts: 16
iTrader: 0 / 0%
Question php - upload but only 3 times ! how to ?

Hello fellas,
say that we have a (mysql) table which includes the field NAME .
Also i have a php script to upload photos .
The NAME is stored every time that one photo is uploaded .

This i want to do is, to set a limit on uploading. I want everyone to be able to upload photos only for 3 times , No More than 3 !
So, i was thinking to make it according the NAME . Par example, if Jason is in my database 3 times Jason, Jason, Jason with some..count(NAME) to find that is 3 times and block him from uploading again ( cause already 3 times he did) .

My question is how can i implement,write this with PHP ..??

Please give me some example and expalin plz

thanks iN advance..
 
Reply With Quote
  #2 (permalink)  
Old 04-04-2007, 08:04 AM
Thanol's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-13-03
Posts: 827
iTrader: 0 / 0%
I'm sure there's a more efficent way than what I'm giving you but this should work:
Code:
//first we're accessing the mysql database and having it count how many times NAME is equal to the variable $name, which you can set as whatever. $count_name = mysql_query("SELECT COUNT(*) FROM $dbtable WHERE NAME='$name'") or die(mysql_error("Failed to Count")); //The results of the query is put into an array, and since we're only getting one thing, we don't need to put it in a loop. $total_counts is an array that contains a number that says how many times that name has been counted $total_counts = mysql_fetch_array($count_name); //since it's in an array you should probably throw it into a different variable to keep everything tidy $counted_name = $total_counts[0];
$counted_name == some integer.
__________________
-Scott
Build a Website : Excel Help

Last edited by Thanol; 04-04-2007 at 08:08 AM.
 
Reply With Quote
  #3 (permalink)  
Old 04-10-2007, 09:41 PM
nster's Avatar
Junior Member
 
Join Date: 11-06-06
Posts: 16
iTrader: 0 / 0%
thanks i ll try to make something with it ..and propably i;ll inform ya later here
 
Reply With Quote
  #4 (permalink)  
Old 04-11-2007, 10:00 AM
StupidScript's Avatar
Senior Member
Latest Blog:
None

 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
"Jason" should only be in the database one time ... he's one user. Why not add a column for "uploads", and increment it each time the logged in user uploads a file? When they get to the upload page, check the field that counts how many times they have (successfully) uploaded, and if it's 3 times, don't display the upload form. Something like:
Code:
if ($counter<3) { print "<form id='uploadForm' ... "; ... print "</form>"; } else { print "You have uploaded the maximum number of files."; }
__________________
James Butler

Where would we be without rhetorical questions?
 
Reply With Quote
  #5 (permalink)  
Old 04-11-2007, 02:18 PM
Arenlor's Avatar
Senior Member
Latest Blog:
None

 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
That's a cool way to count, didn't know about that I just select * and mysql_num_rows but yeah if NAME is a username then just attach the num to them, that way if they delete an upload you just decrement the number.
__________________
Need a page made? Draw a diagram, I suggest using Paint, show the picture with your post, it'll help a lot more than you think. Other questions? Draw a diagram for that too!
 
Reply With Quote
  #6 (permalink)  
Old 04-29-2007, 03:52 PM
nster's Avatar
Junior Member
 
Join Date: 11-06-06
Posts: 16
iTrader: 0 / 0%
Talking

thanks everybody is okay now
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WOW Scary times in the USA intruth Controversial Social Issues 1 09-07-2007 12:24 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 01:16 PM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.