**Long-winded post warning**
SystemWisdom wrote:
Are you saying that the $row variables are arrays? Not strings? They should be strings if you want to explode it into an array, if they are already arrays then you dont need explode()..
I do apologise for the confusion and the lack of data. I got the full fetch display to work at some point a few weeks ago when I was debugging the array content, and unwisely deleted it instead of commenting it out.. which I'll never do again. Each $row is an array of values. Maybe I just don't grok whether I'm
supposed to see the values of every array or not if I output the data fetch.
SystemWisdom wrote:hard to manipulate data if you don't know what it is!!
I know. I feel totally lame. My learning curve for this project has been more of a learning right-angle, so I'm really good in spots and absolutely horrible in others.
SystemWisdom wrote:
So you could do the exact same thing manually like:
Code: Select all
for( $i = 0; $i < count($qcols); $i++ )
$BigBrother .= ", '$qcols[$i]'";
Right. Brilliant.
SystemWisdom wrote:
Though, this may not make any difference until you start dealing with arrays of objects..
I only need to manipulate the values in one location, here, for the express purpose of a database insertion. This occurs at the end of the entire process. Thankfully.
conscience wrote:
Show us your query code, where you are passing that query string to the database (not the DB connection tho) and how you are trying to retrieve results.. maybe even the DB table structure..
OrderHistory structure (INSERT destination):
Code: Select all
Field Type Null Default
itemId int(11) No
datetime varchar(20) Yes NULL
legalname varchar(50) Yes NULL
title varchar(50) Yes NULL
degree varchar(10) Yes NULL
body varchar(60) Yes NULL
email varchar(30) Yes NULL
phone varchar(15) Yes NULL
address varchar(75) Yes NULL
address2 varchar(75) Yes NULL
city varchar(50) Yes NULL
state char(2) Yes NULL
zip varchar(10) Yes NULL
totalcost decimal(8,2) Yes NULL
paymethod varchar(15) Yes NULL
qty0 varchar(5) Yes NULL
item0 varchar(30) Yes NULL
//qty and item fields go up to qty15/item15 until I upgrade the structure.
Indexes:
Keyname Type Cardinality Field
PRIMARY PRIMARY 0 itemId
id UNIQUE 0 itemId
Data Fetch:
Code: Select all
$getItems = "SELECT * FROM cart INNER JOIN items ON cart.itemId = items.itemId WHERE cart.cookieId = '" . GetCartId() . "' ORDER BY items.itemName ASC";
$ItemSet = mysql_query($getItems) or die(mysql_error());
while($row = mysql_fetch_array($ItemSet)) {
//SQL query generation code goes here.
}
The SQL query contains the names of each of the $_POST variables I'm trying to import ($name, $body, etc.) with the items concatenated, named as "$_POST['qty']" and "$_POST['itemName']". I refer to them by number (3 and 5) since its less typing.
GetCardId() returns the SesssionID after some validation.
Items table:
Code: Select all
Field Type Null Default
itemId int(11) No
itemName varchar(50) Yes NULL
itemDegree varchar(10) Yes NULL
itemDesc varchar(250) Yes NULL
itemPrice decimal(4,2) Yes NULL
itemThumb varchar(100) Yes NULL
itemPic varchar(100) Yes NULL
itemLevel varchar(5) Yes NULL
Indexes:
Keyname Type Cardinality Field
PRIMARY PRIMARY 21 itemId
id UNIQUE 21 itemId
Cart table:
Code: Select all
Field Type Null Default
cartId int(11) No
cookieId varchar(50) Yes NULL
itemId int(11) Yes NULL
qty int(11) Yes NULL
Indexes:
Keyname Type Cardinality Field
PRIMARY PRIMARY 61 cartId
id UNIQUE 61 cartId
SystemWisdom wrote:I hope that helps a bit!
I really feel that I owe you something in exchange for your assistance here. This is tedious and annoying, I know, and I'm extremely grateful for your altruism. Let me know if I can PayPal you $10 for a six-pack of microbrews or something for your time.