You are here: Re: multidimensional array in to a MySQL table « PHP Programming Language « IT news, forums, messages
Re: multidimensional array in to a MySQL table

Posted by Stephen Preston on 03/14/06 12:17

Hi

Thanks to you all for replying, and sorry if my explaination was garbled.
The code for the section is as follows.
The first part empties the table first (which it does). After persevering
further last night the code below empties the contents of the table, and the
$result inside the brackets fills one row of the MySQL table with the first
row of the array, then issues the 'Couldn't insert data'.
If I swap the $result is outside the brackets (# commented out below), the
table is emptied again and then the last row of the array fills one row of
the table. 'Couldn't insert data' is not issued though this time.


if(isset($_POST['dataok']))
{
$input = $_POST[input];
include("dataup.inc");
$query1 = "DELETE FROM $tableName";
$result = mysql_query($query1)
or die("Couldn't delete the data.");
echo "All data within $tableName has been deleted!!!<p>";

foreach($input as $row)
{
$query2 = "INSERT INTO $tableName
(level1,level2,level3,illust,item,description,partNo,qua,price,remarks,weight,size,mass)
VALUES
('$row[level1]','$row[level2]','$row[level3]','$row[illust]','$row[item]','$row[description]','$row[partNo]','$row[qua]','$row[price]','$row[remarks]','$row[weight]','$row[size]','$row[mass]')";
$result = mysql_query($query2) or die("Couldn't insert data.");
}
# $result = mysql_query($query2) or die("Couldn't insert
data.");

exit();
} # endif

Still trying to understand Richards first example (my lack of
understanding), not his explaination I think.

Thanks
Stephen

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация