Vanders Posted March 2, 2009 Share Posted March 2, 2009 Hi, I don't know very much PHP, but I'm trying to update a page that generates a CSV from a database. The part that I need to update doesn't pull from the database at all. Here's what I've been able to come up with and it works fine, but it only inserts info for one image. I need to be able to insert info for 8 images. I've tried several things that didn't work. I know this is a simple syntax thing and I'd really appreciate any help. The code I have now: $field[] = 'http://www.websiteaddress.com/Images/' . $carInfo['stock_num'] . '_01.jpg'; Thanks! Vanders Quote Link to comment Share on other sites More sharing options...
Maq Posted March 2, 2009 Share Posted March 2, 2009 Can we see your SQL code? And the code that generates the $field[] array? Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 2, 2009 Share Posted March 2, 2009 And what is wrong with it? It is one assignment, so it assigns one element to an array. If you want to add more elements, you need more code. Quote Link to comment Share on other sites More sharing options...
Vanders Posted March 2, 2009 Author Share Posted March 2, 2009 I need more items in the same field. I can add additional fields, but I can't figure out how to add additional info in this one. I tried this, but it only returns one image link. I just have no clue how to format it so that it puts all the info in one field. Thanks!!! $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_01.jpg'; 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_02.jpg'; 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_03.jpg'; I don't have easy access to the SQL. I can get it but it's a pain. Can we figure something out without it? I didn't create the SQL or the PHP pages. We had a company do that for us, but they aren't around any more. I figured out how to get the one image included by looking through what was there. I've read a little about PHP, but I really only know a tiny amount. Thanks again! Quote Link to comment Share on other sites More sharing options...
phant0m Posted March 2, 2009 Share Posted March 2, 2009 <?php $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_01.jpg'; 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_02.jpg'; 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_03.jpg'; ?> should probably be: <?php $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_01.jpg'; $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_02.jpg'; $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_03.jpg'; ?> Quote Link to comment Share on other sites More sharing options...
Vanders Posted March 2, 2009 Author Share Posted March 2, 2009 Thanks Phantom, but that would create a seperate field for each image. The result that I'm looking for would include all three in one field. The text generated would look like this, "http://www.websitename.com/Images/V123_01.jpg, http://www.websitename.com/Images/V123_02.jpg, http://www.websitename.com/Images/V123_01.jpg" Thanks! Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 2, 2009 Share Posted March 2, 2009 http://www.php.net/manual/en/language.operators.string.php Quote Link to comment Share on other sites More sharing options...
Vanders Posted March 2, 2009 Author Share Posted March 2, 2009 After reading the link, I tried this and it didn't work either. argh. $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_01.jpg' . ',' 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_02.jpg'. ',' 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_03.jpg'; Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 2, 2009 Share Posted March 2, 2009 You've got a bit of a mess with quotes $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_01.jpg' . ',' 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_02.jpg'. ',' 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_03.jpg'; should be $field[] = 'http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_01.jpg, http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_02.jpg, http://www.websitename.com/Images/' . $carInfo['stock_num'] . '_03.jpg'; Quote Link to comment Share on other sites More sharing options...
Maq Posted March 2, 2009 Share Posted March 2, 2009 Or you can just use double quotes : $field[] = "http://www.websitename.com/Images/{$carInfo['stock_num']}_01.jpg,http://www.websitename.com/Images/{$carInfo['stock_num']}_02.jpg,http://www.websitename.com/Images/{$carInfo['stock_num']}_03.jpg"; Quote Link to comment Share on other sites More sharing options...
Vanders Posted March 2, 2009 Author Share Posted March 2, 2009 OH I see! Now it all makes sense. Once you know what's happening with the . and the ' ' it makes sense. For some reason I thought you had to separate each bit of info, only because of the interactivity with the db. Thanks so much for your help! It's working perfectly! Quote Link to comment Share on other sites More sharing options...
Maq Posted March 2, 2009 Share Posted March 2, 2009 No, when all said and done it's just storing a string (varchar), so that's exactly what you have to give it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.