473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP: Number of rows in DB table?

Little frustrated over what seems like should be easy...

Starting with this:
===========================================
$NUMROWS = mysql_query("select count(*) from questions");
echo "NUMROWS = $NUMROWS <br>";

echo get_resource_type($NUMROWS), "<br>";

$COUNTER = mysql_fetch_array($NUMROWS);
if ($COUNTER)
echo "COUNTER = $COUTNER";

echo "<br> fart";
===========================================
My output is this:
===========================================
NUMROWS = Resource id #3
mysql result
COUNTER =
fart
===========================================

From reading around, It seems I should be using one of the PHP mysql_fetch_xxx commands, but I can't get any of them to display the result hidden inside "Resource id #3". When I run the query directly on the database it returns a value of 2 (which is correct). I am not getting any errors reported. I am a total PHP and MySQL neophyte, but I have RTFM. What am I missing here?
Apr 26 '06 #1
2 5941
I'm not sure if this is a mistake in your code or not but if you notice the word counter is misspelled

===========================================
$NUMROWS = mysql_query("select count(*) from questions");
echo "NUMROWS = $NUMROWS <br>";

echo get_resource_type($NUMROWS), "<br>";

$COUNTER = mysql_fetch_array($NUMROWS);
if ($COUNTER)
echo "COUNTER = $COUTNER";

echo "<br> fart";
===========================================
My output is this:
===========================================
NUMROWS = Resource id #3
mysql result
COUNTER =
fart
===========================================
Apr 26 '06 #2
OMG, I just noticed a spelling error =P (as did Sugartonic)
Sorry to waste your time.

I now have:
===================================
$NUMROWS = mysql_query("select count(*) from questions");
$COUNTER = mysql_fetch_array($NUMROWS);
echo "COUNTER = $COUNTER[0]";
===================================
and correctly get:
===================================
COUNTER = 2

Hopefully my next post will be more substantial.
Apr 26 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil Powell | last post by:
Relevancy scores are normally defined by a MySQL query on a table that has a fulltext index. The rules for relevancy scoring will exclude certain words due to their being too short (minimum...
0
by: Phil Powell | last post by:
The table already has a fulltext index and from there I can use the MySQL fulltext search query to get results as well as the relevancy score. The problem I have is that MySQL has a default...
6
by: Jeff Dunnett | last post by:
Hello, I have written the following HTML Form: <html><head><title>Survey</title></head> <body bgcolor="black" text="white" link="#f6b580" vlink="#c0c0ff"> <img src="logo.gif" width="324"...
7
by: Tony Clarke | last post by:
Hi, I'm trying to write a system thats used for about 50 clients that uses html forms and php to log details. The problem is that when a client loads the form page it's given a value which is...
9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
9
by: elyob | last post by:
Hi, I'm looking at storing snippets of details in MySQL about what credit cards a business excepts. Rather than have a whole column for Visa, another for Amex etc ... I am looking at having a...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
12
by: liamo | last post by:
Don't laugh lol I know your all php guru's : ) Ok, so I have little if any knowledge with the programming language php - only having created small enquiry forms. Now I have a client that needs a...
2
by: gvijayasurya | last post by:
11. What are the different tables present in mysql, which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2),ename varchar(10)) ? 12....
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.