Jump to content


Photo

Anyway round this *SOLVED*


  • Please log in to reply
25 replies to this topic

#21 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 16 September 2006 - 09:28 PM

I get this with my test data
[pre]
2006-01-22  1  Widget    25  aaaa          bbbbbb        cccc      dddddddd
2006-02-01  2  Gizmo      15  aaaaaaaaaaa    bb            ccccccccc  dddd 
2006-03-01  3  Wotsit    10  aaaaaaaaaaaaa  bbbbbbbbbbbbb  cccc      dd   
2006-04-01  4  Something  50  aa            bbbb          ccc        d     
[/pre]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#22 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 16 September 2006 - 09:41 PM

It looks like some of your fields may have extra spaces at the end. cjange the bit that gets the max field lengths to

    // get data lengths
    $maxlen=array();
    foreach ($data_rows as $k=>$row)
        foreach($row as $cname=>$val) {
            $data_rows[$k][$cname] = trim($val);
            $maxlen[$cname] = max($maxlen[$cname], strlen(trim($val)));
        }

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#23 cyprus

cyprus
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 16 September 2006 - 10:04 PM

Many thanks. I was thinking there may be an unwanted space somewhere, and whether there was a trim function. I tried your code and it made no difference, however I noticed it to be on one product item where it happens. I went into the database, and found the answer. I had tried adding spaces to the data in the field when I was trying to get columns in line with an ordinary dropdown list code. I removed the bodge that never worked, and hey ho all is well. Everything lines up perfectly. Many thanks again following me through on this nightmare. Best regards

#24 cyprus

cyprus
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 16 September 2006 - 10:27 PM

Just a quick one while this post is still fresh. There are 2 column values, Price and Quantity. Is there an easy way to add to the database data being retrieved for the list, the addition of "£" before the price value/data, and "off" after the quantity values. At the moment all prices look like eg 6.00 and the quanties eg 30.

If its a lot of work then I will give it a miss as you have done enough already. Thanks

#25 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 16 September 2006 - 10:38 PM

Change that same bit of code again to this
    // get data lengths
    $maxlen=array();
    foreach ($data_rows as $k=>$row)
        foreach($row as $cname=>$val) {
            $val = trim($val);
            switch ($cname) {
                case 'Price':       $val = '£' . number_format($val,2); break;
                case 'Quantity':    $val = number_format($val, 0) . ' off'; break;
            }
            $data_rows[$k][$cname] = $val;
            $maxlen[$cname] = max($maxlen[$cname], strlen($val));
        }

This will (I hope) give
Price = £1,234.56
Qty = 1,000 off
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#26 cyprus

cyprus
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 16 September 2006 - 10:56 PM

A resounding yes. Cannot say a big enough thankyou. Have a good weekend.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users