Can"t figure out a difficult conditional statement

Can"t figure out a difficult conditional statement

am 04.06.2010 05:42:54 von Bill Mudry

--=====================_993316132==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

You would think that a relatively simple conditional statement should
be quite easy to get
working --- but after many retries and reworks, this has got me
stumped. I look forward to being shown why and (even better) what
actually will work.

First, lets give everyone access to the knowledge base that I am
building so you can
see what users now see versus what I want them to see.
The site URL is http://www.prowebcanada.com/taxa/.

However, the data pages are within a Frames environment which makes
it hard to read what
each page really is. Therefore I will escape these frames so I can
list the actual files I am
working on and make it easier to follow and understand.

Lets say a reader has chosen to view information on the wood genus of
"acer" (ie. all maples).
The URL would be
http://www.prowebcanada.com/taxa/displaygenera2.php?&genus_n ame=Acer
and information on that genus would show on the top half of the
page. Ignore that and look at
the second part of the page under "Woody Species of Acer".

The Objective - Notice how a reader can choose a particular Acer
species (ie. Maple) and let it follow out
to a data page that would show data on the chosen
wood. If you would have
chosen Acer barbatum, the URL for this data page works out to a successful:
http://www.prowebcanada.com/taxa/displayspecies.php?&species _name=Acer%20barbatum

In recent times, I have been able to add code to show off actual
scans of a limited number of
woods ---- including a decent scan for Acer barbatum. Showing off
actual scans on a species
data page is working quite fine now.

Now go back to the genus page where we started from. What I am trying
to do is to have the
code look ahead to show a small camera icon in front of the species
listings but ONLY for
those that will offer a scan (ie. photo) of each wood that has one
displaying. I do not have
scans for every wood.

You should think that should be an easy job to set up but after
reading up and many tries with
different configurations, I still cannot seem to get this to work
right. At this point, I don't know
why. Either I get no camera icons at all OR icons in front of every
listing when they should
show up only where there are photos installed.

The photos are stored as a path and file name in the
picture_filename1 column of table 'species'. The cells in this column
either have a scan filename and path to the file name stored or a
"". The camera icon should show only if there is a
valid (.jpg) picture stored.

I have echoed all the scan file names for now:
- to show that they do show up and that is not the problem
- to show which species have photos and which don't
- and finally, to show that the camera icon is showing up
even when there is a NULL
stored. That is what should not happen.
Once this is working properly I would comment out or even erase that statement

Assume a successful connection to the database (named taxa by the
way). No use displaying
the code for showing data on one genus. That part is working fine, so
I will list the code for the
lower part. Just so the code is easier to understand, the loop not
only displays all the woody
species but has provisions to start another column if the column gets
too large. The code I am
trying to develop to work properly is inside that loop.

...... Where it seems like a file name is not showing, it actually is
but showing a NULL is the same
as showing ---- nothing(!). Just ignore all the statements commented
out. They have all been
efforts during earlier development and debugging. I can clean that up
some later.

Here, then is the code I have so far (that should work and does not).

As the code will show, $showcamera is set up to display one instance
of a camera icon but it is in a loop that shows all species of a genus.

Thanks in advance for your suggestions,

Bill Mudry,

============================================================ =========
< Upper code left out for relevance and brevity>

//////////////////////////////////////////////////////////// /////////////////////////////
// LISTING SPECIES OF THE CHOSEN WOODY GENUS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// A query now runs to display relevant woody species of the chosen
genus. Choosing a
// species will take the user to a page detailing information on the
chosen species.
//
//////////////////////////////////////////////////////////// /////////////////////////////


echo "

Woody Species of $genus_name

";
//echo "\$generaID is - $generaID";

echo "

Each link leads to more information on the
chosen botanical species

";

mysql_connect($hostname, $username, $password) OR DIE ('Unable to
connect to database! Please try again later.');
mysql_select_db(taxa)
or die(mysql_error());

$query5 = "SELECT * from species where generaID = '$generaID' order
by species_name";

$result5 = mysql_query($query5)
or die(mysql_error());

//var_dump($result5);
$l=-0;
$m=1;



echo "";
echo "";
echo "
";


//////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// Now as each species is generated in a list of the woody species of
the chosen genus, we want to show a small camera
// icon (as images/cameraicon01.jpg) in front of each listed species
ONLY if the species has a scan or photo
// stored in the 'species' table under column 'picture_filename1'.
The program has to look ahead in the 'species'
// table for all of them to see which ones should and which should
not have a camera icon beside them. The whole
// idea is to let readers be informed on which choices include a scan
or photo before choosing. If there is no
// null or empty value in that location, it is assumed that there is
a scan to view.
//////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////

$camera_icon = "images/cameraicon01.jpg";
$showcamera = "...";



if($result5) {
while($row5 = mysql_fetch_array($result5))
{
//echo "\$genus_name is - $genus_name";
extract($row5);
//Echo "extract($row5)";
//Echo "\$row5 is - %row5";
$l++; // counter to set maximum columns lengths

//echo "'\$m is - '.$m";

if ($l>60)
{
echo "
";
$l=0;
};

$picture_filename1 = trim($picture_filename1);

echo "$picture_filename1
"; // Debug statement
to show which entries do have photos attached.

// Here is the main conditional statement area:
if ('$picture_filename1' !== "('' or ''")" )
{
echo $showcamera; // the only time it
should show a camera icon
}
else if ('$picture_filename1' == "('' or ''")
echo "No scan
";

echo '';
//echo "$picture_filename1
";


echo "$m - $species_name";
echo"

\n";
$m++; // counter to increment for the next species


}
}
else echo "No species found";

$species_name="";
echo "

";


// End of display table.
Echo "

";

echo "

End of Listing for Woody Species of
$genus_name

";

echo "";
echo







--=====================_993316132==.ALT--

Re: Can"t figure out a difficult conditional statement

am 04.06.2010 06:22:23 von Keith Davis

--Apple-Mail-21-965401549
Content-Type: text/plain;charset=us-ascii;format=flowed;delsp=yes
Content-Transfer-Encoding: 7bit

if ('$picture_filename1' !== "('' or ''")" )

!== means equal and same variable type.

NULL in the datatbase returns null in the variable. Not the string
'NULL' and not empty string (''), but actual null and I'm not sure
what you mean with the <> around NULL.

Do it like this:

if ($picture_filename1)

Is the easiest way, or if you want to make sure that garbage in the
field doesn't trigger it, do this:

if (stristr($picture_filename1, '.jpg'))

Sent from my magic iPhone,
Keith Davis 214-906-5183

On Jun 3, 2010, at 10:48 PM, "Bill Mudry" wrote:

> You would think that a relatively simple conditional statement
> should be quite easy to get
> working --- but after many retries and reworks, this has got me
> stumped. I look forward to being shown why and (even better) what
> actually will work.
>
> First, lets give everyone access to the knowledge base that I am
> building so you can
> see what users now see versus what I want them to see.
> The site URL is http://www.prowebcanada.com/taxa/.
>
> However, the data pages are within a Frames environment which makes
> it hard to read what
> each page really is. Therefore I will escape these frames so I can
> list the actual files I am
> working on and make it easier to follow and understand.
>
> Lets say a reader has chosen to view information on the wood genus
> of "acer" (ie. all maples).
> The URL would be http://www.prowebcanada.com/taxa/displaygenera2.php?&genus_n ame=Acer
> and information on that genus would show on the top half of the
> page. Ignore that and look at
> the second part of the page under "Woody Species of Acer".
>
> The Objective - Notice how a reader can choose a particular Acer
> species (ie. Maple) and let it follow out
> to a data page that would show data on the chosen
> wood. If you would have
> chosen Acer barbatum, the URL for this data page works out to a
> successful:
> http://www.prowebcanada.com/taxa/displayspecies.php?&species _name=Acer%20barbatum
>
> In recent times, I have been able to add code to show off actual
> scans of a limited number of
> woods ---- including a decent scan for Acer barbatum. Showing off
> actual scans on a species
> data page is working quite fine now.
>
> Now go back to the genus page where we started from. What I am
> trying to do is to have the
> code look ahead to show a small camera icon in front of the species
> listings but ONLY for
> those that will offer a scan (ie. photo) of each wood that has one
> displaying. I do not have
> scans for every wood.
>
> You should think that should be an easy job to set up but after
> reading up and many tries with
> different configurations, I still cannot seem to get this to work
> right. At this point, I don't know
> why. Either I get no camera icons at all OR icons in front of every
> listing when they should
> show up only where there are photos installed.
>
> The photos are stored as a path and file name in the
> picture_filename1 column of table 'species'. The cells in this
> column either have a scan filename and path to the file name stored
> or a
> "". The camera icon should show only if there is a valid
> (.jpg) picture stored.
>
> I have echoed all the scan file names for now:
> - to show that they do show up and that is not the problem
> - to show which species have photos and which don't
> - and finally, to show that the camera icon is showing up
> even when there is a NULL
> stored. That is what should not happen.
> Once this is working properly I would comment out or even erase that
> statement
>
> Assume a successful connection to the database (named taxa by the
> way). No use displaying
> the code for showing data on one genus. That part is working fine,
> so I will list the code for the
> lower part. Just so the code is easier to understand, the loop not
> only displays all the woody
> species but has provisions to start another column if the column
> gets too large. The code I am
> trying to develop to work properly is inside that loop.
>
> ..... Where it seems like a file name is not showing, it actually is
> but showing a NULL is the same
> as showing ---- nothing(!). Just ignore all the statements commented
> out. They have all been
> efforts during earlier development and debugging. I can clean that
> up some later.
>
> Here, then is the code I have so far (that should work and does not).
>
> As the code will show, $showcamera is set up to display one instance
> of a camera icon but it is in a loop that shows all species of a
> genus.
>
> Thanks in advance for your suggestions,
>
> Bill Mudry,
>
> ============================================================ =========
> < Upper code left out for relevance and brevity>
>
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> //////////////////////////////////////////////////////////// ////////
> // LISTING SPECIES OF THE CHOSEN WOODY GENUS
> // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> // A query now runs to display relevant woody species of the chosen
> genus. Choosing a
> // species will take the user to a page detailing information on the
> chosen species.
> //
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> //////////////////////////////////////////////////////////// ////////
>
>
> echo "

Woody Species of $genus_name

";
> //echo "\$generaID is - $generaID";
>
> echo "

Each link leads to more information on the
> chosen botanical species

";
>
> mysql_connect($hostname, $username, $password) OR DIE ('Unable to
> connect to database! Please try again later.');
> mysql_select_db(taxa)
> or die(mysql_error());
>
> $query5 = "SELECT * from species where generaID = '$generaID' order
> by species_name";
>
> $result5 = mysql_query($query5)
> or die(mysql_error());
>
> //var_dump($result5);
> $l=-0;
> $m=1;
>
>
>
> echo " > align='center'>";
> echo "";
> echo "
";
>
>
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> //////////////////////////////////////////////////////////// //////////
> // Now as each species is generated in a list of the woody species
> of the chosen genus, we want to show a small camera
> // icon (as images/cameraicon01.jpg) in front of each listed species
> ONLY if the species has a scan or photo
> // stored in the 'species' table under column 'picture_filename1'.
> The program has to look ahead in the 'species'
> // table for all of them to see which ones should and which should
> not have a camera icon beside them. The whole
> // idea is to let readers be informed on which choices include a
> scan or photo before choosing. If there is no
> // null or empty value in that location, it is assumed that there is
> a scan to view.
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> ///
> //////////////////////////////////////////////////////////// //////////
>
> $camera_icon = "images/cameraicon01.jpg";
> $showcamera = "...";
>
>
>
> if($result5) {
> while($row5 = mysql_fetch_array($result5))
> {
> //echo "\$genus_name is - $genus_name";
> extract($row5);
> //Echo "extract($row5)";
> //Echo "\$row5 is - %row5";
> $l++; // counter to set maximum columns lengths
>
> //echo "'\$m is - '.$m";
>
> if ($l>60)
> {
> echo "
";
> $l=0;
> };
>
> $picture_filename1 = trim($picture_filename1);
>
> echo "$picture_filename1
"; // Debug statement
> to show which entries do have photos attached.
>
> // Here is the main conditional statement area:
> if ('$picture_filename1' !== "('' or ''")" )
> {
> echo $showcamera; // the only time it
> should show a camera icon
> }
> else if ('$picture_filename1' == "('' or ''")
> echo "No scan
";
>
> echo '';
> //echo "$picture_filename1
";
>
>
> echo "$m - $species_name";
> echo"

\n";
> $m++; // counter to increment for the next species
>
>
> }
> }
> else echo "No species found";
>
> $species_name="";
> echo "

";
>
>
> // End of display table.
> Echo "

";
>
> echo "

End of Listing for Woody Species of
> $genus_name

";
>
> echo "";
> echo
>
>
>
>
>
>


This message (including any attachments) may contain confidential or otherwise privileged information and is intended only for the individual(s) to which it is addressed. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message or that arise as a result of e-mail transmission. If verification is required please request a hard-copy version f
rom the sender.

www.pridedallas.com


--Apple-Mail-21-965401549--