Jump to content

Recommended Posts

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

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

<?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

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

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

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.