SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb # of uploads, need some assist

    I have this feature setup for loading a number of songs, however I would like to change the code so it only allows user to upload 4 songs then, see, you have reached the limit.

    How Would you suggest adding code fi to this php code below?

    Code:
    <?php
    
    	
    	$k = 4;
    	//$n=5;
    	for ($i=0, $n=count( $this->songs ); $i < $n; $i++)
    	//for ($i=0, $n=count( $this->songs ); $i < $n; $i++)
    	{
    		$song = &$this->songs[$i];
    		$checked 	= JHTML::_('grid.id',   $i, $song->id );
    		$link_edit = JRoute::_( 'index.php?song&userid='.$this->album->user_id.'&layout=form&id=' . $song->id .'&from=album');
    	
    		?>
    		<tr class="<?php echo "row$k"; ?>">
    		
    			<td>
    				<?php echo $checked; ?>
    			</td>
                <td>
            			<input class="text_area" type="text" name="disc_num_<?php echo $song->id;?>" id="disc_num_<?php echo $song->id;?>" size="3" maxlength="1" value="<?php echo $song->disc_num;?>" />
    			</td>
                <td>
    				<input class="text_area" type="text" name="num_<?php echo $song->id;?>" id="num_<?php echo $song->id;?>" size="3" maxlength="1" value="<?php echo $song->num;?>" />
    			</td>
                <td>
    				<input class="text_area" type="text" name="position_<?php echo $song->id;?>" id="position_<?php echo $song->id;?>" size="3" maxlength="1" value="<?php echo $song->position;?>" />
    			</td>
                <td>
    				<input class="text_area" type="text" name="song_<?php echo $song->id;?>" id="song_<?php echo $song->id;?>" size="20" maxlength="255" value="<?php echo $song->name;?>" />
    			</td>
    
                <td>
    				<a href="<? echo $link_edit; ?>"><img src="components/com_muscol/assets/images/page_white_edit.png" title="<? echo JText::_( 'Edit this song' ); ?>" alt="<? echo JText::_( 'Edit this song' ); ?>" /></a>
    			</td>
            
    
    		</tr>
    		<?php
    		$k = 1 - $k;
    		
    
    	}
    	?>

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    This is something you would typically use a SESSION variable for.

    If you want to stop your users creating multiple sessions, then you have to ask them to log in and record the number of uploads in something like a database or text file.

    But then they can create multiple accounts ... and so on.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •