• Help
  • Search
  • Login
  • Register
  • Home

Forum: web design and graphics community

Celestial Star Forum > Web Development > Coding > Preview It (32) PHP help...?
Pages: [1] 2
« previous next »
  Print  
Author Topic: Preview It (32) PHP help...?  (Read 6889 times)
astrid
Angeling
*
Posts: 15



View Profile WWW
Preview It (32) PHP help...?
« on: August 22, 2004, 08:22:29 PM »

I want to know how to make that counter as to how many have clicked or downloaded something. <.< Can someone please give me a tutorial link or teach me how?
Logged

t comes
      to the
      point where

      i dont
      know how
      to let
      you go
Melfina
Administrator
Valkyrie Randgris
*****
Posts: 1289



View Profile WWW
Preview It (32) PHP help...?
« Reply #1 on: August 23, 2004, 03:54:42 PM »

Sure! (This belongs to Advanced coding ^_- )

Download counter

That's where I learnt to do it ^^ Pretty simple once you get it :P You'll need php and mysql. I think I've seen somewhere how to do it without mysql... but I think it was much more complicated :/ or maybe not... @.@

Though it says download counter, it's a click counter really :S
Logged


MySpace  ~ MySpace Codex ~ Rune Nifelheim
astrid
Angeling
*
Posts: 15



View Profile WWW
Preview It (32) PHP help...?
« Reply #2 on: August 23, 2004, 04:16:54 PM »

Ooops about that I'm sorry ^_^;;; Thank you for the link, I'll look into that. <3
Logged

t comes
      to the
      point where

      i dont
      know how
      to let
      you go
Stolen Pixelite
Incubus
**
Posts: 62



View Profile
Preview It (32) PHP help...?
« Reply #3 on: August 23, 2004, 06:57:38 PM »

its rather easy...

You place the link... direct it to a certain file like download.php?id=1. and in download.php you select the id and Update the count table .

Well It should "LOOK" something like this... as I am a php learner too :P

in listing where you place the link.
Code:
<a href="download.php?id=1">Download</a>

Of course if you are file the link is in is full php you can use Loops and varaibles. Im just making it short.

Now when you are making the counting.
in download.php -
Code:

<?

             // CONNCTION!

   $query = mysql_query("SELECT * FROM `table` WHERE id='$id'") or die (Could Not select. Mysql says" . mysql_error());

              while ($row = mysql_fetch_assoc ($query)) {

                 $id = $row['id'];
                 $name = $row['name'];
                 $url = $row['url'];
                 $counter = $row['counter'];

                        Header("Location:" . $url);

          $update = mysql_query("UPDATE `table` SET counter = counter + 1 WHERE id = '$id'") or die ("Could Not Update. Mysql says" . mysql_error());

?>


Of course you'll want a table. the link Melfina gave you gives you an idead :P. So easy that this code looks a lot like Snow_Whites :P but i Made it without looking...haha.

Edit...gee i wonder how they would get the file...lol added that part in there :P
Logged

 :wub: PHP.
Melfina
Administrator
Valkyrie Randgris
*****
Posts: 1289



View Profile WWW
Preview It (32) PHP help...?
« Reply #4 on: August 23, 2004, 07:05:02 PM »

Really great ^____^ This is a sticky!!
Logged


MySpace  ~ MySpace Codex ~ Rune Nifelheim
Stolen Pixelite
Incubus
**
Posts: 62



View Profile
Preview It (32) PHP help...?
« Reply #5 on: August 23, 2004, 07:06:50 PM »

Kool..Just added little more code since i forgot a portion...lmao...
Logged

 :wub: PHP.
astrid
Angeling
*
Posts: 15



View Profile WWW
Preview It (32) PHP help...?
« Reply #6 on: August 23, 2004, 07:08:22 PM »

Ooh thanks a whole lot *_* I appreciate your help <.< I have to re-code my layouts and stuff anyway, I did it all wrong hahaha~ Thanks again.
Logged

t comes
      to the
      point where

      i dont
      know how
      to let
      you go
Stolen Pixelite
Incubus
**
Posts: 62



View Profile
Preview It (32) PHP help...?
« Reply #7 on: August 23, 2004, 07:16:27 PM »

You're welcome. Glad that I could help out.
Logged

 :wub: PHP.
astrid
Angeling
*
Posts: 15



View Profile WWW
Preview It (32) PHP help...?
« Reply #8 on: August 23, 2004, 07:19:52 PM »

Haha by the way..your avatar *bouncy bouncy* Haha I find myself watching it, it's very interesting XDD
Logged

t comes
      to the
      point where

      i dont
      know how
      to let
      you go
Stolen Pixelite
Incubus
**
Posts: 62



View Profile
Preview It (32) PHP help...?
« Reply #9 on: August 23, 2004, 07:21:12 PM »

lol...dont go off topic...or you get in trouble :P  

yea it is rather bouncy :P
Logged

 :wub: PHP.
astrid
Angeling
*
Posts: 15



View Profile WWW
Preview It (32) PHP help...?
« Reply #10 on: August 23, 2004, 07:23:20 PM »

Shocked <.< I mean thanks again for the tutorial, I'll be sure to use it ^_~
Logged

t comes
      to the
      point where

      i dont
      know how
      to let
      you go
puretaurus21
Guest
Preview It (32) PHP help...?
« Reply #11 on: January 21, 2005, 04:34:10 AM »

Okay I got this stuff alright, the download counter. I even included this in my layout database, but I have another problem. In my database I have 2 tables and each named 'div' and 'tables' but on this code:

Code:
$q2="update div set counter=counter+1 where entryID='$id'";


it says that it only allows the 'ids' of the downloads for the data in only the 'div' table but I want the 'tables' table to be included in the code above as well with out making a new precounter.php that would allow the same thing to happen for the 'tables' table data.

Sorry, if thsi doesn't make sense but it will be helpful to me if you help me figure this out :D
Logged
Melfina
Administrator
Valkyrie Randgris
*****
Posts: 1289



View Profile WWW
Preview It (32) PHP help...?
« Reply #12 on: January 21, 2005, 10:38:14 AM »

Yes, I think I got it. You need to do the same for the divs but for the tables. Then it should be like this:

Code:
$q2="update tables set counter=counter+1 where entryID='$id'";


Jus put the same code on a new file and replace 'div' for 'table' wherever it's needed. Also remember to change that filename (or the path) for the tables' download/preview counter  :wink:
Logged


MySpace  ~ MySpace Codex ~ Rune Nifelheim
puretaurus21
Guest
Preview It (32) PHP help...?
« Reply #13 on: January 21, 2005, 04:28:15 PM »

Erm, yes I know how to do that but can you put the tables in the precounter.php along with the div? Or I do I have to make another precounter for tables ?  Its just that I don't want to make a precounter/download counter for all divs, tables and all the layout platforms.
Logged
Melfina
Administrator
Valkyrie Randgris
*****
Posts: 1289



View Profile WWW
Preview It (32) PHP help...?
« Reply #14 on: January 21, 2005, 06:43:35 PM »

Quote from: "puretaurus21"
Erm, yes I know how to do that but can you put the tables in the precounter.php along with the div? Or I do I have to make another precounter for tables ?  Its just that I don't want to make a precounter/download counter for all divs, tables and all the layout platforms.


I think I got it now xD Yes, you can actually do so by using cases like this:

Code:
<?php 

$mode 
= mysql_escape_string&#40;$_GET['type'&#93;&#41;;

if &#40;!isset&#40;$type&#41; || empty&#40;$type&#41;&#41;
&#123; $type = 'index'; &#125;

switch&#40;$type&#41;
&#123;

case 'div';

// Your query to update the div counter goes here.

break;

case 'tables';

// Your query to update the tables counter goes here.

break;

&
#125;

 
?>


Now to use the counters, you'd do it using a link like yourpreviewfile.php?type=div&id=$id for the div layouts and yourpreviewfile.php?type=tables&id=$id for the table layouts
Logged


MySpace  ~ MySpace Codex ~ Rune Nifelheim
Pages: [1] 2
  Print  
« previous next »
 
Jump to:  

  • Welcome, Guest
  • Members login
  • Register for free

General

  • General
  • New members
  • Announcements
  • Support / Suggestions

Art boards

  • Creative mediums
  • Requests and offers
  • Tutorials
  • Celestial Star tutorials

Web development

  • Coding
  • Web design
  • Advertisements / affiliation

Off-topic

  • The non-sense
  • Ententainment

Go up
eXTReMe Tracker
  • Valid XHTML
  • Valid CSS
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC | Seo4Smf v0.2 © Webmaster's Talks
Loading...