473,465 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Database rows count into HTML webpage

6 New Member
Hi,
I'm trying to get the number of rows from a specific database table to appear as text in an HTML webpage.
Here's the code I have, but can't figure out what's wrong and why it won't display. I have it in the middle of a form.
Any help would be appreciated.


<html>
<body>
<?php
$connection = mysql_connect("localhost", "XUSERX", "XPASSX");
mysql_select_db("XDATABASENAMEX", $connection);
$result = mysql_query("SELECT * FROM xdatabasetablex;);
{
echo $result. "of 200 needed".;
}
?>
</body>
</html>
Apr 18 '07 #1
11 2389
code green
1,726 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query("SELECT * FROM xdatabasetablex
This returns a resource result not an integer. You need [PHP]mysql_num_row($result)[/PHP]
Apr 20 '07 #2
mlfilms
6 New Member
OK, so this is the script then?

<html>
<body>
<?php
$connection = mysql_connect("localhost", "XUSERX", "XPASSX");
mysql_select_db("XDATABASENAMEX", $connection);
mysql_num_row($result);
{
echo $result. "of 200 needed".;
}
?>
</body>
</html>


It doesn't show the number of rows.
Apr 20 '07 #3
code green
1,726 Recognized Expert Top Contributor
No this is the script
[PHP]html>
<body>
<?php
$connection = mysql_connect("localhost", "XUSERX", "XPASSX");
mysql_select_db("XDATABASENAMEX", $connection);
$result = mysql_query("SELECT * FROM xdatabasetablex");
echo mysql_num_rows($result). "of 200 needed".;
?>
</body>
</html>[/PHP]
Apr 20 '07 #4
mlfilms
6 New Member
Thanks. I cannot seem to get this working though. Nothing is showing up
Apr 20 '07 #5
code green
1,726 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM xdatabasetablex
In that case your select statement has returned an empty recordset
Apr 23 '07 #6
mlfilms
6 New Member
There are 19 rows in the database as of today. the database name is tinasti_frgn1 and the table is recipeinfo. I have all that info in the code and the username password, etc.
I'm not sure what I'm doing wrong.
Apr 23 '07 #7
code green
1,726 Recognized Expert Top Contributor
Then get some debugging in and have a look!
[PHP]<html>
<body>
<?php
$connection = mysql_connect("localhost", "XUSERX", "XPASSX");
mysql_select_db("XDATABASENAMEX", $connection)
or die('Failed - Error no '.mysql_errorno().' Message '.mysql_error())
$result = mysql_query("SELECT * FROM xdatabasetablex")
or die('Failed - Error no '.mysql_errorno().' Message '.mysql_error())
echo mysql_num_rows($result).' of 200 needed';
?>
</body>
</html>[/PHP]
When compiling code, continually echo out variables, recordsets and messages otherwise you won't have a clue what is happening.
Apr 24 '07 #8
mlfilms
6 New Member
Still nothing.
I tried it on a blank page and nothing. It's quite puzzling.
Apr 26 '07 #9
code green
1,726 Recognized Expert Top Contributor
tried it on a blank page and nothing. It's quite puzzling
Can you echo ANYTHING out on to the page?
Apr 26 '07 #10
mlfilms
6 New Member
Nothing at all.
May 2 '07 #11
code green
1,726 Recognized Expert Top Contributor
Well your page is wrong. I suspect you have error reporting turned off. Use this line before connecting to the DB [PHP]error_reporting(E_ALL | E_STRICT);[/PHP]This will switch on error reporting for the duration of the script. Also try and echo something out. Change the entry point of your script to [PHP]<html><body>Hello there<?php echo 'Hello Again';[/PHP]But if your script is not compiling you wil not get this far
May 2 '07 #12

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

Similar topics

5
by: krystoffff | last post by:
I currently have PostgreSQL 7.1 installed on a server with about 700 Mb of RAM. I have many problems of speed with a database I created. For example, it took almost 12 sec to run the query...
5
by: rob | last post by:
Hi to all. I am pretty new to using Access and am having a problem I hope someone can help me with. I want to access a MS-Access database from a web page. I have managed to get it "sort" of...
4
by: Haydnw | last post by:
Hi, I'd like to put a load of database results (several rows for 5 fields) into a two-dimensional array. Now, this may be a really stupid question, but can someone give me a pointer for how to...
6
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I...
10
by: shsandeep | last post by:
The ETL application loaded around 3000 rows in 14 seconds in a Development database while it took 2 hours to load in a UAT database. UAT db is partitioned. Dev db is not partitioned. the...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
by: DennisBetten | last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel. What does this code do: As the title says, this code is capable of...
1
Curtis Rutland
by: Curtis Rutland | last post by:
How To Use A Database In Your Program Part II This article is intended to extend Frinny’s excellent article: How to Use a Database in Your Program. Frinny’s article defines the basic concepts...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.