mac007 Posted November 2, 2008 Share Posted November 2, 2008 Hello, all: I was trying to understand this long script that I have and found this line in which parentheses appear, I dont recall seeing that at all before... this script takes image-paths from an IMAGES table that are related to an ITEMS table thru each record's ID... so, pretty much what it does, it fetches the common images that belong to a specific record and shows it along with the record... can you explain how these parentheses work here? their meaning? it's not like they are if-else statements, are they? Thanks! <CODE> $images = mysql_query("SELECT * FROM item_image WHERE item_id = '{$item['item_id']}'"); while($image = mysql_fetch_assoc($images)){ echo '<img src="images/thumbs/'.$image['image_file'].'" />'; </CODE> Link to comment https://forums.phpfreaks.com/topic/131035-solved-can-sombody-please-explain-to-me-this-mysql_query-line-please-with-parentheses/ Share on other sites More sharing options...
trq Posted November 2, 2008 Share Posted November 2, 2008 Are you talking about the {} curly braces? They are there because complex variables (ie arrays and objects) should be surrounded by curly braces when within a string. Another way to write the exact same thing would have been.... $images = mysql_query("SELECT * FROM item_image WHERE item_id = '". $item['item_id'] ."'"); Link to comment https://forums.phpfreaks.com/topic/131035-solved-can-sombody-please-explain-to-me-this-mysql_query-line-please-with-parentheses/#findComment-680323 Share on other sites More sharing options...
mac007 Posted November 2, 2008 Author Share Posted November 2, 2008 thanks Thorpe... Yes, I am talking about the curly braces inside the mysql query. OK, I'm still a bit confused... I do see that this part: '{$item['item_id']}' refers to the "while" array $item, specifically the item_id field, so is that the only time I would have a need to use the brackets in there?? strange to do it that way, when the other way you mention seems just a fine.. or clearer even.. Link to comment https://forums.phpfreaks.com/topic/131035-solved-can-sombody-please-explain-to-me-this-mysql_query-line-please-with-parentheses/#findComment-680326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.