GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   MySql dumb question (maybe) :) (https://gfy.com/showthread.php?t=315010)

MichaelP 06-19-2004 02:23 PM

MySql dumb question (maybe) :)
 
Is there a simple way to show how many entries from a database ?

like " select * FROM thistable limit= total,1..." well you get the idea :)

Thnaks in advance :glugglug

AndrewKanuck 06-19-2004 02:24 PM

How about using count?

lilj 06-19-2004 02:25 PM

Quote:

Originally posted by egonetworks
How about using count?

AndrewKanuck 06-19-2004 02:25 PM

that's:

select count(*) from table

just incase you've never used it before

cjnet 06-19-2004 02:28 PM

not really i don't think..

in php the easiest way would be:

$query = "SELECT * FROM TABLE"
$result = mysql_query($query) or die("Failed to Get Crap");
$count = mysql_num_rows($result);

i'm pretty sure.. if that helps =O :2 cents:

MichaelP 06-19-2004 03:09 PM

Quote:

Originally posted by cjnet
not really i don't think..

in php the easiest way would be:

$query = "SELECT * FROM TABLE"
$result = mysql_query($query) or die("Failed to Get Crap");
$count = mysql_num_rows($result);

i'm pretty sure.. if that helps =O :2 cents:

Thank you but i tried it and it doesn,t work... Maybe if I can just show the highest ID from the db it would be ok too :)

JSA Matt 06-19-2004 03:13 PM

Quote:

Originally posted by egonetworks
select count(*) from table
if that's not the answer, we don't understand the question

MichaelP 06-19-2004 03:16 PM

Quote:

Originally posted by JSA Matt
if that's not the answer, we don't understand the question
Ho you REALLY WELL understood it, it is just that I tried this nad it didn,t work.. Sorry guy I am not very used with MySql queries yet :)

include_once("sql_include.php"); /= this is where i connect to DB

$sql = "SELECT count(*) FROM tblEntries";
$result = SQL_Query($sql);

echo $result ;

I know I am not that far but not there yet :)

JSA Matt 06-19-2004 03:29 PM

Code:

$query = mysql_query("SELECT COUNT(*) FROM table")or die(mysql_error());
    list($rows) = mysql_fetch_row($query);

echo $rows;


MichaelP 06-20-2004 07:21 AM

Ok got it

include_once("sql_include.php");
$sql = "SELECT * FROM thistable ORDER BY id DESC LIMIT 0 , 1";
$result = SQL_Query($sql);
while($row = mysql_fetch_array($result["ResultSet"]))
{
print "" . $row["id"] . "" ;
}


Thanks to all for your help. it is very appreciated :)

:thumbsup

s9ann0 06-20-2004 07:23 AM

whats wrong with

select count(*) from table

?

Ash@phpFX 06-20-2004 07:42 AM

using count() is the most efficient way

WombRaider 06-20-2004 08:17 AM

Here's another way that's worked for me:

$query = mysql_query("SELECT * FROM tableName");
$qty = mysql_num_rows($query);
echo $qty;

Hope that helps.


All times are GMT -7. The time now is 01:52 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123