Research that work with numbers but not on alphabetical stri

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

lunatic
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Feb 21, 2003 4:13 am

Research that work with numbers but not on alphabetical stri

Postby lunatic » Fri Feb 21, 2003 4:16 am

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, from a multiple choice form, 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.

Code: Select all

 

/ 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 $seno; global $vita; global $fianchi; global $altezza; global $taglia; global $scarpe; global $occhi; global $capelli;

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

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

   $f = str_replace("[>SENO<]","$seno",$f);            // this is a number field
   $f = str_replace("[>VITA<]","$vita",$f);            // this is a number field
   $f = str_replace("[>FIANCHI<]","$fianchi",$f);      // this is a number field
   $f = str_replace("[>ALTEZZA<]","$altezza",$f);      // this is a number field
   $f = str_replace("[>TAGLIA<]","$taglia",$f);        // this is a number field
   $f = str_replace("[>SCARPE<]","$scarpe",$f);        // this is a number field
   $f = str_replace("[>OCCHI<]","$occhi",$f);          // this is an alphabetic field
   $f = str_replace("[>CAPELLI<]","$capelli",$f);      // this is an alphabetic field
   
   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)) {
      
      $seno = $row["seno"];
      $vita = $row["vita"];
      $fianchi = $row["fianchi"];
      $altezza = $row["altezza"];
      $taglia = $row["taglia"];
      $scarpe = $row["scarpe"];
      $occhi = $row["occhi"];
      $capelli = $row["capelli"];
      

// declare numeric string

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

//   $occhiresult = $occhiselect;
//   $capelliresult = $capelliselect;

   // 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 (($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 == "all") else ($occhiselect == $occhi))
                  AND $capelliresult == $capelli
               
         //   end alphabetical string comparison... but doesn't work!! the search wont work!

             )
      {
      
      // this echo the results on a template

      echo pageresult("search_result.tml");
      
[/code]

lunatic
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Feb 21, 2003 4:13 am

there's not someone?

Postby lunatic » Mon Feb 24, 2003 2:16 am

there's not someone? :( :(


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest