Jump to content


Photo

Total Database Records


  • Please log in to reply
27 replies to this topic

#21 BigDog

BigDog

    Young Padawan

  • Members
  • Pip
  • 277 posts
  • Gender:Male
  • Location:Orange County, California
  • Interests:Running, building computers, PC games and BMX and programming.

Posted 19 March 2008 - 04:44 PM

Those XXXs are the same thing as the post i did above, I just added the new $count var.

Besides giving you the sudo, i,with the help of matt, gave you all the code. Just put it together.

Edited by BigDog, 19 March 2008 - 04:45 PM.


#22 ian mullen

ian mullen

    Young Padawan

  • Members
  • Pip
  • 22 posts
  • Location:UK
  • Interests:Television, Computers, Internet.

Posted 19 March 2008 - 04:53 PM

$query = mysql_query("SHOW TABLE STATUS");

while($tbl = mysql_fetch_array($query))
{
$ttlrows = $tbl[Rows];
}

$totalrows = 0;
while($tbl = mysql_fetch_array($query))
{
$totalrows .= $tbl[Rows];
}

So that is supposed to work? It's pasting 0 =S

Yep - thank you both for that. That's why I come to P2L - I know if it isn't in a tutorial, someone on the forum will eventually help out!

#23 BigDog

BigDog

    Young Padawan

  • Members
  • Pip
  • 277 posts
  • Gender:Male
  • Location:Orange County, California
  • Interests:Running, building computers, PC games and BMX and programming.

Posted 19 March 2008 - 04:55 PM

You are welcome, but here, lets optimize that:

$query = mysql_query("SHOW TABLE STATUS");

$totalrows = 0;
while($tbl = mysql_fetch_array($query))
{
$totalrows .= $tbl[Rows];
}


#24 ian mullen

ian mullen

    Young Padawan

  • Members
  • Pip
  • 22 posts
  • Location:UK
  • Interests:Television, Computers, Internet.

Posted 19 March 2008 - 04:57 PM

That's displaying "021111" ?

Once this all works, I promise you I'll have learned it and totally understand it. That's how I learn everything!

#25 BigDog

BigDog

    Young Padawan

  • Members
  • Pip
  • 277 posts
  • Gender:Male
  • Location:Orange County, California
  • Interests:Running, building computers, PC games and BMX and programming.

Posted 19 March 2008 - 05:02 PM

$query= mysql_query("SHOW TABLE STATUS");
$count = 0;
while($tbl = mysql_fetch_array($query))
{
$count = $count + $tbl[Rows];
} 
echo $count;

That works. I'm 100% sure :)

#26 ian mullen

ian mullen

    Young Padawan

  • Members
  • Pip
  • 22 posts
  • Location:UK
  • Interests:Television, Computers, Internet.

Posted 19 March 2008 - 05:08 PM

That works!!! It's alive!!!!!!

Thank you so much BigDog and Mr Matt! You've been big helps - and I have learned this!

#27 Mr. Matt

Mr. Matt

    Moderator

  • Validating
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 19 March 2008 - 05:11 PM

What I was trying to work towards was this:

<?php

$sql = mysql_query( "SHOW TABLES" );
while( $table = mysql_fetch_array( $sql ) ) {

	$count = mysql_num_rows( mysql_query( "SELECT `id` FROM `" . $table['0'] . "`" ) );

	//// OR

	list( $count ) = mysql_fetch_row( mysql_query( "SELECT COUNT( `id` ) FROM `" . $table['0'] . "`" ) );

	///-------

	$total += $count;

}

echo $total; //// Echos the total number of rows

?>

Two methods mixed into one there. For someone who has been coding for two years, i am very supprised tbh.

Matt

#28 ian mullen

ian mullen

    Young Padawan

  • Members
  • Pip
  • 22 posts
  • Location:UK
  • Interests:Television, Computers, Internet.

Posted 19 March 2008 - 05:28 PM

Like I said, I've always worked with the absolute basics because I've never built a complex website. Now that I'm building one, I need to start learning this stuff.

I'm quite embarrassed now. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users