Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2007, 04:17 AM
Authorized User
 
Join Date: Dec 2006
Location: , , Sweden.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default saving data from a array

Hi
I want to save data from a array.

Database looks like this;
Code:
id  artikel    jan   feb   mars
1     101        0     0      0
2     103        0     0      0        
3     109        0     0      0
and my code looks like this;

Code:
          $artikel = mysql_query("SELECT artikel FROM interndeb") or die(mysql_error('hittar inga artiklar'));

          // HTML-tabellens formatering - tabellstart
          echo "<table border='1' bordercolor='#FFAA2A' bgcolor='#FFFFD4' cellspacing='0' cellpadding='3'>";
          echo "<tr bgcolor='#C4E7C9' align=center><td>Artikel</td><td width='45'>JAN</td><td width='45'>FEB</td><td width='45'>MARS</td><td width='45'>APRIL</td><td width='45'>MAJ</td><td width='45'>JUNI</td><td width='45'>JULI</td><td width='45'>AUG</td><td width='45'>SEP</td><td width='45'>OKT</td><td width='45'>NOV</td><td width='45'>DEC</td><td width='50'>TOTALT</td></tr>";

          #---- Hämtar data och sparar den i interndeb-tabellen ----#
          while($row = mysql_fetch_array( $artikel ))
            {
                 #---- kollar ifall det är dax för art. 130 ----#
                $trans = mysql_query("SELECT *,SUM(nettovikt) as vikt FROM trans where artikel='$row[artikel]' and status='2' and kund='101' and transtid between '2007-01-01 00:00:00' and '2007-01-31 23:59:59' group by artikel;") or die(mysql_error('hittar ingen vikt'));
                $vikt = mysql_fetch_array( $trans );
                echo "artikel:" .$row[artikel];
                echo "  vikt:" .$vikt[vikt] . "<br />";
                if($vikt[vikt]=='')
                {
                    echo "<td align=right>0</td></tr>";
                    $save = "UPDATE interndeb SET jan='0' WHERE artikel='$row[artikel]'";
                    mysql_query($save)or die(mysql_error());
                }
                else
                echo "<td align=right>" .$vikt[vikt] . "</td></tr>";
                $save = "UPDATE interndeb SET jan='$vikt[vikt]' WHERE artikel='$row[artikel]'";
                mysql_query($save)or die(mysql_error());

            }
            echo "</table>";

the output looks like this, including the error message...

Code:
artikel:101 vikt:102
artikel:103 vikt:109.29
Data truncated for column 'jan' at row 2
As you can see the first artikel works fine, but when it comes to the second he wont save the data.

Can anyone help me in the right direction??
Regards
Hylsan

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Data with Report latingntlman Reporting Services 0 March 18th, 2008 04:52 PM
Data Cache not saving rturner003 ASP.NET 2.0 Professional 1 August 8th, 2007 07:29 PM
Error for saving data csharpa SQL Server 2005 0 February 21st, 2007 07:48 AM
Saving Form Data Earl Hickey ASP.NET 1.0 and 1.1 Basics 5 July 25th, 2006 01:10 PM
Saving data from an array into a variable cutovoi Excel VBA 1 January 7th, 2004 10:09 AM



All times are GMT -4. The time now is 03:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.