Jump to content

Help with the Alt Tag Using a PHP call


bluewaves

Recommended Posts

<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
Share on other sites

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
Share on other sites

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