Jump to content

Recommended Posts

Hi,

could you help me with this snippet of code I need to complete my project.

 

Each time "Download" is clicked I need to decrement the downloads by 1, then once downloads reaches 0, the download function becomes disabled. How do I do this?

 

for ($i=1; $i <= $num_cart_items; $i++)

 

{

 

echo ("<td>" . $keyarray["item_name".$i]. "</td><td align=left>" . $keyarray["option_name1_".$i]. "</td><td align=left>"  . $keyarray["option_selection1_".$i] . "</td><td align=center>");

 

 

echo ($keyarray["option_name2_".$i]. "</td><td align=left>"  . $keyarray["option_selection2_".$i] . "</td><td align=\"center\">". $keyarray["quantity".$i] ."</td></tr>");

 

 

//problem is here (i think)

 

echo "<tr><td><a href=\"http://www.test.com/" . $keyarray["item_name".$i] . ".mp3\">Download</td></tr>";

 

 

 

}

 

 

 

echo ("</table><br><br>");

 

any help would be greatly appreciated!

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/54960-problem-with-php-mysql-paypal-project/
Share on other sites

for ($i=1; $i <= $num_cart_items; $i++)

{

echo ("<td>" . $keyarray["item_name".$i]. "</td><td align=left>" . $keyarray["option_name1_".$i]. "</td><td align=left>"  . $keyarray["option_selection1_".$i] . "</td><td align=center>");


echo ($keyarray["option_name2_".$i]. "</td><td align=left>"  . $keyarray["option_selection2_".$i] . "</td><td align=\"center\">". $keyarray["quantity".$i] ."</td></tr>");


//problem is here (i think)         

echo "<tr><td><a href=\"http://www.test.com/\" . $keyarray["item_name".$i] . ".mp3\">Download</td></tr>";

   

}



echo ("</table>

");

take that piece of code and stick it in yours and c if it helps, i think you forgot to escape the string after the test.com

for ($i=1; $i <= $num_cart_items; $i++)

 

{

 

echo ("<td>" . $keyarray["item_name".$i]. "</td><td align=left>" . $keyarray["option_name1_".$i]. "</td><td align=left>"  . $keyarray["option_selection1_".$i] . "</td><td align=center>");

 

 

echo ($keyarray["option_name2_".$i]. "</td><td align=left>"  . $keyarray["option_selection2_".$i] . "</td><td align=\"center\">". $keyarray["quantity".$i] ."</td></tr>");

 

 

//problem is here, returns errors, I cannot get the part below to work, any ideas? 

 

if($i>0){

echo "<tr><td><a href=\"http://www.test.com/\" . $keyarray["item_name".$i] . ".mp3\">Download</td></tr>";

i--;

}

else

{

echo"<tr><td>Download Limit reached</td></tr>"; 

}

echo ("</table>

 

");

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.