Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Italy
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Research that work with numbers but not on alphabetical strings - what's wrong?

    This is a script that search for parameters in a mysql database. Some fields in the db contains data numbers
    and the others contains alphabetic data.
    The script had to search, by user choice, for numbers or for alphabetical or for numbers and alphabetical data together.
    Maybe, IMHO, there's some problems in the string comparison part.
    I 've a minimal php experience but I'm trying to learn. If someone can and want to help I'll be very grateful.
    Ciao.


    PHP Code:

    // declare row color

    $coloredtable "2";

    // connect to Mysql

    $link mysql_connect ($dbhost$dbuser$dbpass);
    mysql_select_db($dbname);

    // start PAGERESULT 

    function pageresult($fil)
    {
        global 
    $coloredtable;
        global 
    $foto; global $codice; global $nome; global $cognome; global $anni; global $seno; global $vita

    global 
    $fianchi; global $altezza; global $taglia; global $scarpe; global $occhi; global $capelli; global 

    $esperienze; global $thumb; global $immagine1; global $immagine2; global $immagine3; global $immagine4; global 

    $polaroid; global $email; global $controllo1; global $controllo2; global $controllo3; global $controllo4

    global 
    $controllo5; global $datains;

        
    $f implode("",file($fil));

        if (
    $coloredtable == "1") {$coloredtable "2";} else {$coloredtable "1";};
        
    $f str_replace("[>COLOREDTABLE]","$coloredtable",$f);

        
    $f str_replace("[>CODICE<]","$codice",$f);
        
    $f str_replace("[>NOME<]","$nome",$f);
        
    $f str_replace("[>COGNOME<]","$cognome",$f);
        
    $f str_replace("[>ANNI<]","$anni",$f);
        
    $f str_replace("[>SENO<]","$seno",$f);
        
    $f str_replace("[>VITA<]","$vita",$f);
        
    $f str_replace("[>FIANCHI<]","$fianchi",$f);
        
    $f str_replace("[>ALTEZZA<]","$altezza",$f);
        
    $f str_replace("[>TAGLIA<]","$taglia",$f);
        
    $f str_replace("[>SCARPE<]","$scarpe",$f);
        
    $f str_replace("[>OCCHI<]","$occhi",$f);
        
    $f str_replace("[>CAPELLI<]","$capelli",$f);
        
    $f str_replace("[>ESPERIENZE<]","$esperienze",$f);
        
    $f str_replace("[>THUMB<]","$thumb",$f);
        
    $f str_replace("[>IMMAGINE1<]","$immagine1",$f);
        
    $f str_replace("[>IMMAGINE2<]","$immagine2",$f);
        
    $f str_replace("[>IMMAGINE3<]","$immagine3",$f);
        
    $f str_replace("[>IMMAGINE4<]","$immagine4",$f);
        
    $f str_replace("[>POLAROID<]","$polaroid",$f);
        
    $f str_replace("[>EMAIL<]","$email",$f);
        
    $f str_replace("[>CONTROLLO1<]","$controllo1",$f);
        
    $f str_replace("[>CONTROLLO2<]","$controllo2",$f);
        
    $f str_replace("[>CONTROLLO3<]","$controllo3",$f);
        
    $f str_replace("[>CONTROLLO4<]","$controllo4",$f);
        
    $f str_replace("[>CONTROLLO5<]","$controllo5",$f);
        
    $f str_replace("[>DATAINS<]","$datains",$f);

        return 
    $f;
    }
    // end PAGERESULT 

    // start query

        
    $result mysql_query("SELECT * FROM `nuke_xragazze`");
        
    $totalRows_link mysql_num_rows($result);
        while (
    $row mysql_fetch_array($result)) {
            
    $foto $row["foto"];
            
    $codice $row["codice"];
            
    $nome $row["nome"];
            
    $cognome $row["cognome"];
            
    $anni $row["anni"];
            
    $seno $row["seno"];
            
    $vita $row["vita"];
            
    $fianchi $row["fianchi"];
            
    $altezza $row["altezza"];
            
    $taglia $row["taglia"];
            
    $scarpe $row["scarpe"];
            
    $occhi $row["occhi"];
            
    $capelli $row["capelli"];
            
    $esperienze $row["esperienze"];
            
    $thumb $row["thumb"];
            
    $immagine1 $row["immagine1"];
            
    $immagine2 $row["immagine2"];
            
    $immagine3 $row["immagine3"];
            
    $immagine4 $row["immagine4"];
            
    $polaroid $row["polaroid"];
            
    $email $row["email"];
            
    $controllo1 $row["controllo1"];
            
    $controllo2 $row["controllo2"];
            
    $controllo3 $row["controllo3"];
            
    $controllo4 $row["controllo4"];
            
    $controllo5 $row["controllo5"];
            
    $datains $row["datains"];

    // declare numeric string

        
    $senomas explode("-"$Senoselect);
        
    $vitamas explode("-"$Vitaselect);
        
    $fianchimas explode("-"$Fianchiselect);
        
    $altezzamas explode("-"$Altezzaselect);
        
    $etamas explode("-"$etaselect);
        
    $tagliamas explode("-"$tagliaselect);
        
    $scarpemas explode("-"$scarpeselect);
        
    // declare alphabetical strings

        
    $occhiresult $occhiselect
        
    $capelliresult $capelliselect;
        
    $settoreresult $settoreselect;
        
    $carnagioneresult $carnagioneselect;
        
    $provinciaresult $provinciaselect;
        
    $codiceresult $codiceselect;
        

        
    // start numeric string comparison... 

        
    if ( (($seno >= $senomas[0]) and ($seno <= $senomas[1])) 
            AND ((
    $vita >= $vitamas[0]) and ($vita <= $vitamas[1]))
                AND ((
    $fianchi >= $fianchimas[0]) and ($fianchi <= $fianchimas[1]))
                    AND ((
    $altezza >= $altezzamas[0]) and ($altezza <= $altezzamas[1]))
                         AND ((
    $anni>= $etamas[0]) and ($anni <= $etamas[1]))
                              AND ((
    $taglia >= $tagliamas[0]) and ($taglia <= $tagliamas[1]))
                                   AND ((
    $scarpe >= $scarpemas[0]) and ($scarpe <= $scarpemas[1]))

                
    //    end numeric string comparison... 
                
                //    start alphabetical string comparison... 

                       
    AND (if ($occhiselect == "tutti") else ($occhiselect == $occhi))
                          AND 
    $capelliresult == $capelli
                            
    AND $settoreresult == $settore 
                              
    AND $carnagioneresult == $carnagione 
                                
    AND $provinciaresult == $provincia 
                                   
    AND $codiceresult == $codice 
                
    //    end alphabetical string comparison... but doesn't work!! the search wont work!

                     
    )
            {
            
            
    // this echo the results on a template

            
    echo pageresult("/home/sites/site3/web/rogue/modules/ricerca/search_result.tml"); 

  • #2
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Italy
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    there's not someone?

    there's not someone?

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    ... its a bit hard knowing where to start , especially with all that code and not being sure what exactly you are doing (i.e. you understand this project , we do not so its a little hard to debug)

    in saying that ... this line looks as though it ought to be causing some problems

    "AND (if ($occhiselect == "tutti") else ($occhiselect == $occhi))"

    what happens if you remove that line ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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