Jump to content

[SOLVED] Proper syntax to dynamically generate lines of code


imimin

Recommended Posts

Now its printing out like this:

 

fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00241.jpg", "", ""]<br />fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00256.png", "", ""]

Link to comment
Share on other sites

I just need my output to print like this:

 

fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00210.jpg", "", ""]
fadeimages[1]=["http://www.patternsofjoy.com/images/thumbs/POJ00222.jpg", "", ""]
fadeimages[2]=["http://www.patternsofjoy.com/images/thumbs/POJ00224.jpg", "", ""]

 

maybe my choice of words was not correct when I mentioned putting a <BR> between each line.  I just assumed that is what I needed to get the output to look like the above output?

Link to comment
Share on other sites

Thank you!

 

I set it up like this:

 

<?php

/*$cat = mysql_real_escape_string($_GET['cat']);*/
$cat='all';

$get_items = "SELECT * FROM poj_products WHERE cat='$cat'";
$get_items = mysql_query($get_items);
   while($item_row = mysql_fetch_assoc($get_items))
   {
   extract($item_row);
   echo 'fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/'.$item_row['img-no_path'].'", "", ""]';
   \n;
   }
?>

 

and I am still getting:

 

fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00241.jpg", "", ""]fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00256.png", "", ""]fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00257.png", "", ""]

Link to comment
Share on other sites

You have absolute no clue as to what you're doing I assume?  ;)

 

echo 'fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/'.$item_row['img-no_path'].'", "", ""]' . '\n';

 

You need to learn the basics of both php and html it seems. Also, I would advice you to read about new line characters. <br> is a line break in html, nowhere else.

Link to comment
Share on other sites

I just ordered a good book on the subject, looking for ward to it  8) !

 

Just tried the last code you gave me and now I get this as an output:

 

fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00241.jpg", "", ""]\nfadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00256.png", "", ""]

Link to comment
Share on other sites

Being generated server side so when you look at source on a web browser you see it.  It's the first part of a JS.  I know the code works with the JS, my only problem is at this point to get it to print correctly to:

 

fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/POJ00210.jpg", "", ""]
fadeimages[1]=["http://www.patternsofjoy.com/images/thumbs/POJ00222.jpg", "", ""]
fadeimages[2]=["http://www.patternsofjoy.com/images/thumbs/POJ00224.jpg", "", ""]

Link to comment
Share on other sites

Yeah, I knew it was generated serverside but not where it was displayed, that is the only thing that matters  ;)

 

Now that we know it's javascript you're producing I was a bit too quick. \n will work fine but since you use single quotes for the echoed strings it will not work properly. You need to break out of them:

 

echo 'fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/'.$item_row['img-no_path'].'", "", ""]' . "\n";

 

That should do it.

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.