Jump to content

[SOLVED] Syntax Help


Vanders

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