Jump to content

MySQL num rows based on two tables


CravenBW

Recommended Posts

I'm trying to get the number of rows based on two tables... it's not quite working right. Can anyone see anything wrong with the code below or give me another idea by any chance? The date stuff still needs some work but it works for right now. My main issue right now is getting active working which checks for usernames that are both signed up and validated then is supposed to take those usernames and see if they've logged in more then 1 time but that part isn't working. :-(

[code]<?php
print '<table cellspacing="5px" style="text-align: center;"><tr style="text-align: left;"><td><b>DATE</b></td><td><b>SIGNUP</b></td><td><b>VALIDATED</b></td><td><b>ACTIVE</b></td></tr>';

$link = mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ("database", $link);

$date = date("mdY",strtotime("-10 day"));
$today = date("mdY:");

while($date < $today) {
  $sign = mysql_query("SELECT * FROM users WHERE signdate LIKE '$date%'");

  $validate = mysql_query("SELECT * FROM users WHERE validate != '' AND signdate LIKE '$date%'");
  $active = mysql_query("SELECT username FROM users WHERE validate LIKE '$today%' AND signdate LIKE '$today%'");
 
    print '<tr><td><b>'.substr($date,0,2).'/'.substr($date,2,2).'/'.substr($date,4).'</b></td>';

    print '<td>'.mysql_num_rows($sign).'</td>';

    print '<td>'.mysql_num_rows($validate).'</td>';
  while($row = mysql_fetch_array($active)) {
    $numrows = mysql_query("SELECT * FROM ftp WHERE username='$row[username]' AND ftp_logincount >= '2'");
    print '<td>'.mysql_num_rows($numrows).'</td></tr>';
  }

  if ($date < "".date("m",strtotime("-1 month"))."31".date("Y")."") {
    $date = $date + 10000;
  }
  elseif ($date > "".date("m")."00".date("Y")."") {
    $date = $date + 10000;
  }
  elseif ($date = "".date("m",strtotime("-1 month"))."31".date("Y")."") {
    $date = date("m");
    $date .= "01";
    $date .= date("Y");
  }
   
}
print '</table>';
?>[/code]
Link to comment
Share on other sites

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.