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 Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/ 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? Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-774986 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. Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-774987 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! Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-774996 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'; ?> Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775000 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! Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775006 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 Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775009 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'; Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775016 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'; Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775019 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"; Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775022 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! Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775024 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. Link to comment https://forums.phpfreaks.com/topic/147627-solved-syntax-help/#findComment-775025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.