Results 1 to 3 of 3

Thread: Query Result Issue

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Query Result Issue

    I'm having difficulties in this. Here's a shortened version of my 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>
    It's returning "1:" instead of the total count of the query.
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: count() vs. mysql_num_rows()

    Your query is WAY too complicated. Consider shortening it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Query Result Issue

    Posts split to separate new thread
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width