#16 (permalink)  
Old 07-02-2008, 09:53 PM
Registered User
 
Join Date: Jul 2004
Posts: 247
Quote:
Originally Posted by curtiss View Post
First of all, yes, I am saying that it appears to be the $searchthese that's causing the problem.

The rest of your SQL query does not get built if $searchTheseArr is empty, and that appears to be what's happening.
I did a document.write in the JavaScript to find out how it's writing the URL and found out that there was an & missing.

But I still have to text the rest of what you said. Thanks!
Reply With Quote
  #17 (permalink)  
Old 07-02-2008, 10:02 PM
Registered User
 
Join Date: Jul 2004
Posts: 247
Quote:
Originally Posted by curtiss View Post
The syntax of the COUNT() function can be found on the MySQL manual pages. Basically, all you do is add "COUNT(*)" in place of where you would normally use just "*". Using the COUNT query will simply return a single number telling you how many rows would be returned if you were to take out the COUNT() function from your query.

In other words, if you were to use a query like:
Code:
SELECT COUNT(*) FROM mytable
and there were 100 rows in "mytable", the result of that query would be 100.

Adding an alias for the COUNT function makes it easier to refer to the value that's returned by the query. So, in other words, you could use either of the following queries (they are both exactly the same, actually):
Code:
SELECT COUNT(*) totalrows FROM mytable
SELECT COUNT(*) AS totalrows FROM mytable
Then, you would simply refer to $rs['totalrows'] to get the number that is returned (assuming that $rs is the name of the array you are using to store your recordset).

Of course, if you place a limit on your results, and use the COUNT function with that limit, the COUNT function is only going to return whatever your limit is. So, if you use LIMIT 10 in your query, and there are at least ten rows that match the criteria in your query, the COUNT function is only going to return the number 10.

Therefore, when using the COUNT function, you want to take out the LIMIT phrase from your query. Other than that, you would just use the exact same query you are using to pull the information from your database in the first place.
Ok this is what the sql says:
Quote:
SELECT COUNT(*) AS totalrows FROM bible WHERE 1=1 AND CASE WHEN text_data LIKE '%offer%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%sacrifice%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%peace%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%offering%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%offering%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%covereth%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%inwards%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%inwards%' THEN 1 ELSE 0 END > 3 LIMIT 0, 10
When I use SELECT COUNT(*) AS totalrows it shows no results except 1:.
Reply With Quote
  #18 (permalink)  
Old 07-03-2008, 03:51 PM
Registered User
 
Join Date: Jul 2004
Posts: 247
I followed what you said but something is still causing for it not to work:
Quote:
SELECT count(*) AS totalrows FROM bible WHERE 1=1 AND CASE WHEN text_data LIKE '%offering%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%tabernacle%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%congregation%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%Aaron%' THEN 1 ELSE 0 END > 3
I removed the limit
I put:
PHP Code:
echo $row['totalrows']."<br />"
which gives blank.

And the result doesn't show. When I remove the count(*) AS totalrows then I get the result again.
Reply With Quote
  #19 (permalink)  
Old 07-03-2008, 05:59 PM
Registered User
 
Join Date: Jul 2004
Posts: 247
Here's a shortened version of the code:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php 
$con 
mysql_connect("","root","");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("kjv"$con);

$sql "SELECT count(*) AS totalrows FROM bible WHERE 1=1 AND";
$sql .= " CASE WHEN text_data LIKE '%angel%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%appeared%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%flame%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%midst%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%looked%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%behold%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%burned%' THEN 1 ELSE 0 END + CASE WHEN text_data LIKE '%consumed%' THEN 1 ELSE 0 END > 3";
//$sql .= " LIMIT 0, 10";
$result mysql_query($sql) OR exit( 'Error: ' mysql_error());
        function 
highlight $str$words )
        {
        
            if ( 
is_array$words ) ) {
                                
rsort($words);
                
$words array_map'preg_quote'$words );
                
$words join$words'|' );
            } else {
                
$words preg_quote( (string)$words );
            }
            
//$re = '<span style="color: red; font-weight:bold;">$1</span>';
                
$color[0] = "red";
                
$color[1] = "blue";
            
//for($c=0; $c < 8; $c++){
                //echo $color[$c]."<br />";
                
$re '<span style="color: '.$color[0].'; font-weight:bold;">$1</span>';
                
//}
            
return preg_replace'/\b(' $words ')\b/i'$re$str );
        }
        
echo 
$row['totalrows']."<br />";
$recCount 1;
while(
$row mysql_fetch_array($result)){
        echo 
"<span id='regular[]' style='padding: 5px; background-color: #D2C5A0; display: block; border: 1px solid #7C7C7C; color: black;'>";
        echo 
"<span style='font-weight: bold; color: black; background-color: #B4B3A9; display: block; border: 1px solid #7C7C7C;'>"."<span style='font-weight: normal;'> ".$recCount."</span> ".$row["book_title"]." ".$row["chapter"].":".$row["verse"]." ";
        echo 
"</span>\n";    

        
$str   $row['text_data'];

        
//var_dump( highlight( $str, $newSearchTheseArr));
        
echo highlight$str$newSearchTheseArr);
        echo 
"</span><br />\n";
        
$recCount++;
}  

mysql_close($con);
?>
</body>
</html>
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
paging with JavaScript and ASP "Next" "Previous" gilgalbiblewhee Programming and Scripting 1 07-05-2007 10:19 AM


All times are GMT -5. The time now is 06:38 PM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter