Jump to content

Variable assignment problem


hdbrandon

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.

 

Archived

This topic is now archived and is closed to further replies.

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