Results 1 to 6 of 6

Thread: query question

  1. #1
    Join Date
    Jun 2004
    Posts
    5

    Unanswered: query question

    function get_options($options){
    $db = dbConnect("mydatabase");
    $opt = explode("~", $options);
    $i = count($opt);
    $y = 0; //<tr></tr> counter
    ?>
    <tr>
    <td bgcolor="#FFFFFF"><img src="inc_assets/img/one.gif" alt="" width="100" height="5"></td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#414141" class="padding2"><font color="#FFFFFF"><strong>Vehicle Options:</strong></font></td>
    </tr>
    <tr>
    <td bgcolor="#FFFFFF"><img src="inc_assets/img/one.gif" alt="" width="100" height="2"></td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <table>
    <?
    for($x=0;$x<$i;$x++){
    $query = "SELECT DESCRIPTION from options WHERE CIDOPTI = '".$opt[$x]."'";

    $result = mysql_query( $query );
    $error = mysql_error();
    //echo "$query<br><br>";
    //echo "$error<br>";
    $row = mysql_fetch_array( $result );

    if($row[0] != ""){
    if($y == "0"){
    echo "<tr>";
    }//end if

    $cellString = "<td align=\"right\"><p class=\"norm\">•&nbsp;&nbsp;</p></td><td align=\"left\"><p class=\"norm\">$row[0]&nbsp;&nbsp;&nbsp;</p></td>";
    echo $cellString;

    $y++;
    if($y == "2"){
    $y = 0;
    echo "</tr>";
    }//end if
    }//$row[0] if

    }//end for loop
    ?>
    </table>
    </td>
    </tr>
    <?
    }//end function
    Ok this is my problem, I am using this query to pull a description based on the matching characters of CIDOPTI = '".$opt[$x]."'" However I need the variables to be exact, ie..case sensitive or with exact characters, as the decscriptions are different for each combo of characters....ie Tj and TJ both have different description values.

    Any Ideas?

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    In Mysql I feel there is not option for this. May be this works in news version, though I have never tried that.

    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  3. #3
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    I'm not at a machine to test this, but I think you can get case sensitivity in MySQL by casting the strings to binary and then compare.

  4. #4
    Join Date
    Jun 2004
    Posts
    5
    I know thats how I would do it with a pure mysql query, but I was unsure if thats what I would do in php, and where the binary call would be put.

    thanks

  5. #5
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    I think this will work?
    PHP Code:
    $query "SELECT DESCRIPTION from options WHERE CIDOPTI = BINARY '".$opt[$x]."'"
    You can send any SQL through php.

  6. #6
    Join Date
    Jun 2004
    Posts
    5
    Thats how I would write it if I was using coldfusion directly, and I think it will work. But what I did was make the db table CIDOPTI have the binary attributes in the db itself. That seems to work so far.

    Thanks again

Posting Permissions

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