473,320 Members | 2,177 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,320 software developers and data experts.

count

hi i got the count functon working but this it the first time i have ever used it
[php]$_result = mysql_query(" SELECT COUNT( * ) FROM `table` WHERE `colum` = '$sid' ");
echo "$_result Phones Supported"; [/php]
i can tell my echo is wriong. but i dont know what i should be doing here

Please enclose your posted code in [code] tags (See How to Ask a Question). Please use [code] tags in future.

MODERATOR
Mar 23 '08 #1
5 1891
DavidPr
155 100+
You may try something like this:

[PHP]$query = "SELECT COUNT(*) AS numrows FROM `table` WHERE colum = '$sid'";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
}
echo "$numrows Phones Supported";[/PHP]

or

[PHP]$query = "SELECT COUNT(*) FROM `table` WHERE colum = '$sid'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$number = $row['COUNT(*)'];
}
echo "$number Phones Supported"; [/PHP]
Mar 23 '08 #2
Works great,

thank you i just couldn't figure out how to show the results when the query itsself was the result and not generating variables.

this is going in my bookmarks lol

thanks again
Mar 23 '08 #3
Markus
6,050 Expert 4TB
Or, if i understand your problem, you could use the mysql_num_rows()'s function.

[php]
$_query = mysql_query("...");
$_rows = mysql_num_rows($_query);
echo $_rows;
[/php]
Mar 23 '08 #4
Or, if i understand your problem, you could use the mysql_num_rows()'s function.

[php]
$_query = mysql_query("...");
$_rows = mysql_num_rows($_query);
echo $_rows;
[/php]
this bit will solve the overall problem thanks
Mar 24 '08 #5
Markus
6,050 Expert 4TB
this bit will solve the overall problem thanks
Welcome!

See you around.

Markus.
Mar 24 '08 #6

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

Similar topics

22
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: ...
6
by: Geetha | last post by:
I searched in the Oracle documents what count (1) meant and I could not find an answer. Can some one explain what Oracle does internally when use count (1) VS count (*). Thank you very much in...
1
by: JD | last post by:
Hi guys I'm trying to write a program that counts the occurrences of HTML tags in a text file. This is what I have so far: #include <stdio.h> #include <stdlib.h> #include <string.h> ...
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
23
by: Gary Wessle | last post by:
Hi I have a vector<charwhich looks like this (a d d d a d s g e d d d d d k) I need to get the biggest count of consecutive 'd'. 5 in this example I am toying with this method but not sure if...
1
by: heckstein | last post by:
I am working in Access 2002 and trying to create a report from our company's learming management system. I am not a DBA and most of my SQL knowledge has been self taught through trial and error. I...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
3
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php,...
7
by: Chris | last post by:
I am trying to increase/decrease the value of $_SESSION by 1 after clicking on a link e.g index.php?gotoWk=nxtWk and index.php? gotoWk=lstWk. I'm sure you will get the drift if you look at the code...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.