MadLittleMods Posted December 29, 2010 Share Posted December 29, 2010 Alright more on my affiliate page which you guys helped me build last night. Thanks again I want to count the number of times one of the affiliates is clicked. So each one has to have its own impression number. I have my array set up like so: - i see that impression is now 0 and needs to be changed to a variable etc like $aff_blah1_impressions // affiliates array for affiliates page $affiliates = array( array( "title" => "aff_blah1", "image" => "http://aff_blah1.net/images/aff_blah1.png", "href" => "http://aff_blah1.net/", "start_date" => "1/1/2011", "impressions" => "0" ), array( "title" => "aff_blah2", "image" => "http://aff_blah2.net/images/aff_blah2.png", "href" => "http://aff_blah2.net/", "start_date" => "1/1/2011", "impressions" => "0" ), array( "title" => "aff_blah3", "image" => "http://aff_blah3.net/images/aff_blah3.png", "href" => "http://aff_blah3.net/", "start_date" => "1/1/2011", "impressions" => "0" ), ); // affiliates array end I have seen some examples but they all use a text file. Is there any way to have it stored in the database? I was thinking it would somehow be in the link with like a onClick (which is java) that would run a php function. What i am trying to figure out is the best way to store it and have only one function for impressions made on each affiliate. Any keyword search terms or links would be very helpful! Can also contact through AIM: [email protected] Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/ Share on other sites More sharing options...
revraz Posted December 29, 2010 Share Posted December 29, 2010 Store the actual link in a database. The clickable URL should then route to a page that can pass the "ID" of the URL clicked, reference it in the database, increment the count, then launch the URL. Just a thought off the top of my head how I would go about doing it. Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152424 Share on other sites More sharing options...
MadLittleMods Posted December 29, 2010 Author Share Posted December 29, 2010 revraz I want impressions to be a variable $aff_blah2_impressions_count but do not know how to put it in. When put in with no quotes or single quotes it gives me a bunch of errors. How should i put it into the array? "title" => "aff_blah2", "image" => "http://aff_blah2.net/images/aff_blah2.png", "href" => "http://aff_blah2.net/", "start_date" => "1/1/2011", "impressions" => "0" Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152440 Share on other sites More sharing options...
trq Posted December 29, 2010 Share Posted December 29, 2010 Post the code where you have attempted this. Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152441 Share on other sites More sharing options...
MadLittleMods Posted December 29, 2010 Author Share Posted December 29, 2010 Alright that is where everything is called.. (attached) Array is in subs.php (smf, if you are familiar) Whole array: /// affiliates array for affiliates page $affiliates = array( array( "title" => "aff_blah1", "image" => "http://aff_blah1.net/images/aff_blah1.png", "href" => "http://aff_blah1.net/", "start_date" => "1/1/2011", "impressions" => "0" ), array( "title" => "aff_blah2", "image" => "http://aff_blah2.net/images/aff_blah2.png", "href" => "http://aff_blah2.net/", "start_date" => "1/1/2011", "impressions" => "0" ), array( "title" => "aff_blah3", "image" => "http://aff_blah3.net/images/aff_blah3.png", "href" => "http://aff_blah3.net/", "start_date" => "1/1/2011", "impressions" => "0" ), ); // affiliates array end [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152444 Share on other sites More sharing options...
MadLittleMods Posted December 29, 2010 Author Share Posted December 29, 2010 Wait the attachments does what i am wanting to do. Let me look at my smf code for this and see if i can decipher it. Every time you click the attachment link it goes up 1. Well here is my lead on smf - have to go *sigh* (will look closer tommorrow but here it is) // Assuming there are attachments... if (!empty($message['attachment'])) { echo ' <div id="msg_', $message['id'], '_footer" class="attachments smalltext"> <div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', ';">'; $last_approved_state = 1; foreach ($message['attachment'] as $attachment) { // Show a special box for unapproved attachments... if ($attachment['is_approved'] != $last_approved_state) { $last_approved_state = 0; echo ' <fieldset> <legend>', $txt['attach_awaiting_approve']; if ($context['can_approve']) echo ' [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; echo '</legend>'; } if ($attachment['is_image']) { if ($attachment['thumbnail']['has_thumb']) echo ' <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /></a><br />'; else echo ' <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '"/><br />'; } echo ' <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" /> ' . $attachment['name'] . '</a> '; if (!$attachment['is_approved'] && $context['can_approve']) echo ' [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; echo ' (', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />'; } // If we had unapproved attachments clean up. if ($last_approved_state == 0) echo ' </fieldset>'; echo ' </div> </div>'; } Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152447 Share on other sites More sharing options...
MadLittleMods Posted December 30, 2010 Author Share Posted December 30, 2010 Alright I have everything in a db and i am using a while loop now. is there any way to use java onClick to make $row[impressions] +1 Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152823 Share on other sites More sharing options...
trq Posted December 30, 2010 Share Posted December 30, 2010 is there any way to use java onClick to make $row[impressions] +1 You mean Javascript? That would require Ajax. We have an Ajax board here. Quote Link to comment https://forums.phpfreaks.com/topic/222866-counting-clicks-on-linkanything/#findComment-1152829 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.