Displaying SQL Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VictorProfundus
    New Member
    • Mar 2008
    • 2

    Displaying SQL Table

    Hello!

    I have been working on an affiliate link system. A user would click a php link that would add 1 to the count of a certain affiliate, by ID and then return the user to that affiliate page.

    My problem comes when I wish to display a table for my affiliates for them to see how many clicks they have and such.

    Right now, here is my code for the table :

    Code:
    <?php
    
      echo "<table border=1 cellpadding=0 cellspacing=3><tr><td align=center>Affiliate ID Number</td><td align=center>Name</td><td align=center>Number of Clicks</td><td align=center>Payment</td><td align=center>Comments</td></tr>";
    
      for ($i=0; $i<$num; $i++) {
    	  if ($tmp = mysql_fetch_array($result)) {
    		  extract($tmp);
    
    		  echo "<tr><td align=center>$id</td>";
    		  echo "<td align=center>$name</td>";
    		  echo "<td align=center>$count</td>";
    		  echo "<td align=center>$paid</td>";
    		  echo "<td align=center>$comments</td></tr>";
    	  }
      }
    
      echo "</table>";
    
    ?>
    For some reason this isn't working with my page.

    Does anyone have a simpler way of doing this?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Whatever happened to the code leading up to the $result? Maybe the error is in your select, so it won't display anything. Show that code leading to the $result resource id.

    Ronald

    Comment

    • VictorProfundus
      New Member
      • Mar 2008
      • 2

      #3
      okay...here is something like what the entire page would look like:

      Code:
      <?php
      
      include ('header.php');
      
      
        mysql_connect("localhost", "username", "P*A*S*S*W*O*R*D");
        @mysql_select_db("my database") or die( "Unable to connect to database");
        $result = mysql_query("SELECT * FROM linkcount");
      
        $num = mysql_num_rows($result);
      
        mysql_close();
      
      include ('table.php');
      
      ?>
      The table.php then would be my previous post.

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Hi pal, just put your mysql_close() function end of the page.
        [code=php]
        <?php
        include ('table.php');
        mysql_close();
        ?>
        [/code]

        Comment

        Working...