leeandrew Posted February 13, 2008 Share Posted February 13, 2008 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 More sharing options...
haku Posted February 13, 2008 Share Posted February 13, 2008 SELECT COUNT(*) FROM table_name WHERE book1='link_goes_here' OR book2='link_goes_here' ...and so on. Link to comment https://forums.phpfreaks.com/topic/90829-sql-count-help/#findComment-465573 Share on other sites More sharing options...
Isityou Posted February 13, 2008 Share Posted February 13, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.