1

I'm trying to count how many rows that have the same value as a variable.

Then I wanna echo out the number that is calculated in the mysql query! Is this possible?

Here is a image of my database:

http://img812.imageshack.us/img812/333/9jr1.png

Sorry for my bad English and if the question is hard to understand (new to this stuff)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
myhrmans
  • 35
  • 6

3 Answers3

0

There are two different approaches here. If you're looking for a specific value and know it in advance, you can do something as simple as:

select count(*) as count from table where column = 'value';

Alternatively, if you're just looking for a count of duplicate values, you could go with something like:

select count(*) as count, column from table group by column;

That will give you two columns: your column of values and how many occurrences there are of each value.

CaseySoftware
  • 3,105
  • 20
  • 18
0

Execute a SQL query like this:

SELECT COUNT(*) FROM yourtablename WHERE yourcolumnname = yourvariablevalue;
Vlad Schnakovszki
  • 8,434
  • 6
  • 80
  • 114
0

Here it is from your old question

$query= "SELECT pic_name, count(pic_name) as count FROM hulebild_likes where pic_name='$bild_id'";

$likesf = mysqli_query($con, $query);
$row=mysqli_fetch_array($likesf);
echo $row['count'];
Hamza
  • 1,593
  • 2
  • 19
  • 31