Jump to content

strange result from table query


macinslaw

Recommended Posts

I have a simple query that I am restricting to the first 4 character, however instead of the first 4 characters I am getting only the characters from the end of the field.

 

The information in the field resembles: 4285-002

 

My result should be: 4285

 

What I am getting is: -002

 

The following is the code to pull the dat from field 'Dest':

    $dest=odbc_result($rs1, 'Destination');
        $deststrcount=1;
        $deststr = $dest;
        $deststr = str_split($deststr,4);
        foreach($deststr as $destv){
          if ($deststrcount<="1"){
            $desttext=$destv;
            $destnew = "DEST[1,$deststrcount]\t$desttext\r\n";

            $strcount=$strcount+1;
            }

 

-Thanks for your help.

 

Mac

Link to comment
https://forums.phpfreaks.com/topic/70471-strange-result-from-table-query/
Share on other sites

Okay, sorry....I now understand what the "explode" post meant above, unfortunately, I cannot for the life of me find out how to do what I want to do. 

 

Cooldude, thanks so much for following up with your second post.  I have the code and understand now what you were trying to tell me.

 

I have the hardest time following the foo examples that are the lifeline to these programming languages, I learn best by point blank example and trial and error.

 

Thanks so much for your time and your effort on this issue.  I owe you one.

 

-Mac

this line:

        $deststr = $dest;

is pointless, just say

$string = explode("_",$deststr,4);

$number = $string[1];

 

and echo out $number to see it.

 

A lot of functions you think you have to build on your own for strings/arrays pre exsit and you just have to find them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.