[Typo3-dev] sql question ;)
Johannes Reichardt
mailbox at gramba.net
Mon Apr 26 12:47:23 CEST 2004
hi joh,
that looks quite complicated for just a comparison ;)
just another question: how can i show a value in php as bitstring?
- Johannes
>>i want to make a sql condition like this
>>
>>AND checkboxfield=16
>>
>>i have severeal cheboxes which are saved binary in one field, but
>>actually i don´t know how to access them for sql. i tried to do it that
>>
>>
>way:
>
>
>>AND checkboxfield&(checkboxnumber², 16 in this case)
>>
>>but this doesnt work
>>
>>
>
>Try using something like this:
>
>$st="select features from whatever where uid=" . $row["uid"];
> $rs = mysql_query ($st) or die ("Query $st failed");
> $rr = mysql_fetch_array($rs);
> $Features=$rr[0];
> $ValidFeatures=array();
> $k=1;
> $wfcounter = 0;
> for ($m=0; $m<10; $m++)
> {
> if ($Features & $k)
> {
> $ValidFeatures[$m]=1;
> }
> else
> {
> $ValidFeatures[$m]=0;
> }
> $k *= 2;
> }
>
>This will fill the array $ValidFeatures bitwise out of a 10bit value in the
>database.
>
>Joey
>
>
>_______________________________________________
>Typo3-dev mailing list
>Typo3-dev at lists.netfielders.de
>http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
>
>
>
More information about the TYPO3-dev
mailing list