bluewaves Posted July 10, 2010 Share Posted July 10, 2010 <span class='floatleft'><img src=" . $list['BigImage'] . " alt= 'Girly Checks - ". $list['Name'] . "' border='0' /><br /> I can't figure out how I can get the alt tag to read girly checks and then the name of the item. Can anyone help? I've tried all kinds of variations with the " and the ', but I don't understand the rules that govern their usage. Thanks. Link to comment https://forums.phpfreaks.com/topic/207373-help-with-the-alt-tag-using-a-php-call/ Share on other sites More sharing options...
kenrbnsn Posted July 10, 2010 Share Posted July 10, 2010 Can you show us the context where the snippet is used. It doesn't make any sense as it stands now. Ken Link to comment https://forums.phpfreaks.com/topic/207373-help-with-the-alt-tag-using-a-php-call/#findComment-1084182 Share on other sites More sharing options...
pornophobic Posted July 10, 2010 Share Posted July 10, 2010 Assuming that you're printing the html completely from PHP, like so: <?php echo "<span class='floatleft'><img src=" . $list['BigImage'] . " alt= 'Girly Checks - ". $list['Name'] . "' border='0' /><br />"; ?> Or whatever variation of quotes you have, I can see your error already. If you use double quotes, you won't need to use concatenations with it, you can simply just put your variables in the HTML straight up. <?php echo "<span class='floatleft'><img src='$list['BigImage']' alt= 'Girly Checks - $list['Name'] ' border='0' /><br />"; ?> If you want to use single quotes in the PHP, which it would probably be better if you did in this case, you would either have to escape your single quotes in the HTML being produced, or use double quotes in the HTML. Escaping the single quotes for the HTML using single quotes in PHP: <?php echo '<span class=\'floatleft\'><img src=\'' . $list['BigImage'] . \'' alt=\'Girly Checks - ' . $list['Name'] . '\' border=\'0\' /><br />'; ?> Using double quotes in your HTML with single quotes in PHP: <?php echo '<span class="floatleft"><img src="' . $list['BigImage'] . '" alt="Girly Checks - "' . $list['Name'] . '" border="0" /><br />"; ?> I'm also assuming that you've filled the $list array with all your data that you need, if not that could be another problem, but it sounds like you're having trouble with how to use the quotations. Personally, I would use the one of the last two as they use less memory, more precisely, I would use the last one as it's less confusing and looks neater. Hope that helped! Link to comment https://forums.phpfreaks.com/topic/207373-help-with-the-alt-tag-using-a-php-call/#findComment-1084201 Share on other sites More sharing options...
bluewaves Posted July 10, 2010 Author Share Posted July 10, 2010 would you mind taking a look at the rest of the call. I think my quotes are wrong there too. echo "<td><a href='". $list['Link'] . "' rel='nofollow' title='" . $list['Name'] . "' target='_blank'> <span class='floatleft'><img src=" . $list['BigImage'] . " alt='" . $list['Name'] . "' border='0' /><br /> <font face='arial' size='1'>" . $list['Name'] . "</a><br />" . $list['Description'] . "<br />Price: $" . $list['Price'] . "</font></span></td>\n"; Link to comment https://forums.phpfreaks.com/topic/207373-help-with-the-alt-tag-using-a-php-call/#findComment-1084229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.