Jump to content

Recommended Posts

I'm pulling text from a database to use as the alt= for a photo gallery.  Also, each picture has a longer description.  If the description does not exist (ie table field is empty), the alt= text should act as both.  Simple enough but its not working?

 

$fname=mysql_result($result,$i,'filename');
						$username=mysql_result($result,$i,'userID');
						$store=mysql_result($result,$i,'store');
						$date=mysql_result($result,$i,'date');
						$altText=mysql_result($result,$i,'alt');
						$descText=mysql_result($result,$i,'descText');

						//if no photo story, use altText as such.
						if(($descText=='') || ($descText==' ') || ($descText == null)){
							  $descText == $altText;
						}

					echo"
						<td valign='top'>
							<a href='$url/gallery/image.php/image.jpg?width=800&height=800&image=$url/gallery/$fname' rel='lightbox[pictures]' title='$descText'>
								<img src='$url/gallery/image.php/image.jpg?width=75&height=75&image=$url/gallery/$fname' alt='$altText' border='0' />
							</a>
						</td>
					";

 

I've tried both ways- $altText==$descText and $descText ==$altText.  Shouldnt it be as above?

Website is still in production, but see http://qa.theapron.com for an idea of what I mean.  This is being used on conjunction with the lightbox script.

Link to comment
https://forums.phpfreaks.com/topic/240725-variable-assignment-problem/
Share on other sites

Sorry, I wasnt clear.  And, @nightslyr-thanks I took your advice and am using empty.

 

The db has a short description(use for the alt= hover) and longer description for when the picture is expanded(lightbox).  Never will both fields be empty. 

 

The problem: if their is a short description, use it as the alt=.  If their is a longer description, use that when picture is expanded.  If one of the two fields are empty, use the other to take its place.

 

So, for instance, picture #27-the last one. 

The database is:

altText: cowboy boot

descTest:Have you heard of people of home depot?

 

$date=mysql_result($result,$i,'date');
						$altText=mysql_result($result,$i,'alt');
						$descText=mysql_result($result,$i,'descText');

						//if no photo story, use altText as such.
						if(empty($descText)){
							    $descText = $altText;
						}
						else if(empty($altText)){
							$altText = $descText;
						}
						else{
						}

 

 

It seems to be working now.  Thanks.  I think my cookies were screwing me up too.

 

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.