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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.