Jump to content

SQL count help


leeandrew

Recommended Posts

I'm trying to show the number of times something appears in a cell.

 

Users bookmark URL's on my site, a maximum of 6, and they go into cells named book1, book2, book3, book4, book5 & book6... just the URL of the bookmarked page.

I'd like to be able to show on the individual pages how many times they are currently bookmarked. I.E. How many times does `http://www.phpfreaks.com` appear in a cell. I'm struggling to find a code, only row counts.

Link to comment
https://forums.phpfreaks.com/topic/90829-sql-count-help/
Share on other sites

Do you mean something like this?

 

Heres a script that should work if you change the sql statement:

 

<?php
$sql = "SELECT COUNT(*)
          FROM {table name goes here}
          WHERE book1 = {name of the bookmark goes here}";

$result = mysql_query($sql);
$row = mysql_fetch_row($result);

// Will print how many times {name of bookmark goes here} came up in the same column
echo $row[0];
?>

Link to comment
https://forums.phpfreaks.com/topic/90829-sql-count-help/#findComment-465611
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.