[PHP] Problem with Not displaying HTML if data not found
I am trying to develop a page that, in certain places, I only want it to display the and s if data is found for a given field. For example, if I only have an image for the first floorplan of a house, I do NOT have an image for the second floorplan of a house, then show the first floorplan image only.skip over that next row because the field in the db is empty. The problem that I'm having is that the syntax that I've been using to define "empty" in the db field does not always work. The code reads: if ($result[FLRPLAN_2]<>" ") { printf (""); printf (""); printf (" Second Floor Plan: ") ; printf ("") ; printf (""); printf ("") ; echo "'"; printf (" ") ; printf (" "); }; if ($result[FLRPLAN_3]<>" ") {; printf (""); printf (" Third Floor Plan: "); printf (" "); printf (" "); printf (" "); printf (""); echo "'"; printf (" "); printf (" "); }; I have tried: 1. if ($result[FLRPLAN_3]<>" ") {; 2. if ($result[FLRPLAN_3]<>"") {; 3. if ($result[FLRPLAN_3]<>'') {; 4. if ($result[FLRPLAN_3]<>' ') {; 5. if ($result[FLRPLAN_3]<>NULL) {; and none seem to work correctly (i.e. blank field in db, but HTML row shows up with missing image..or image is in db, but no HTML row shows up. If it helps, each of the "image" fields are varchar(125)basically I just have the name of the image file, and then a pointer to the web server directory structure Any ideas would be greatly appreciated. Thanks. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with Not displaying HTML if data not found
When I changed this line, it still gives me the same problem. My db field is a varchar(125)...could that have anything to do with it? Basically, the first time, without data in the field...it works fine and the is not displayed, but when I add data back into the field, nothing changes...its like it does not recognize that something is back in the field. I did a commit on the db each time, and cleared the browser cache, etc. Mark "Martin Towell" <[EMAIL PROTECTED]> wrote in message 6416776FCC55D511BC4E0090274EFEF5034CFB9D@EXCHANGE">news:6416776FCC55D511BC4E0090274EFEF5034CFB9D@EXCHANGE... > what about > if (strlen($result["FLRPLAN_3"]) > 0) > > > > -Original Message- > From: markbm [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 23, 2002 2:02 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Problem with Not displaying HTML if data not found > > > I am trying to develop a page that, in certain places, I only want it to > display the and s if data is found for a given field. For example, > if I only have an image for the first floorplan of a house, I do NOT have > an image for the second floorplan of a house, then show the first floorplan > image only.skip over that next row because the field in the db is empty. > > The problem that I'm having is that the syntax that I've been using to > define "empty" in the db field does not always work. The code reads: > > if ($result[FLRPLAN_2]<>" ") { >printf (""); > printf (""); > printf (" Second Floor Plan: > ") ; > > printf ("") ; > printf (""); > printf ("") ; > echo " src='http://www.website.com/index_files/main_files/$planid/"; . > mysql_result($result, 0,'FLRPLAN_2')."'>'"; > printf (" ") ; > printf (" "); > }; > > > > if ($result[FLRPLAN_3]<>" ") {; > printf (""); > printf (" > Third Floor Plan: "); > printf (" "); > printf (" "); > printf (" "); > printf (""); > echo " src='http://www.website.com/index_files/main_files/$planid/"; . > mysql_result($result, 0,'FLRPLAN_3')."'>'"; > printf (" "); > printf (" "); > }; > > > I have tried: > > 1. if ($result[FLRPLAN_3]<>" ") {; > 2. if ($result[FLRPLAN_3]<>"") {; > 3. if ($result[FLRPLAN_3]<>'') {; > 4. if ($result[FLRPLAN_3]<>' ') {; > 5. if ($result[FLRPLAN_3]<>NULL) {; > > and none seem to work correctly (i.e. blank field in db, but HTML row shows > up with missing image..or image is in db, but no HTML row shows up. If > it helps, each of the "image" fields are varchar(125)basically I just > have the name of the image file, and then a pointer to the web server > directory structure > > Any ideas would be greatly appreciated. Thanks. > > Mark > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Retrieving/Displaying hyperlinked images with PHP
I am trying to build a "product detail" page that pulls data from a MYSQL database using PHP. The data for the page includes product images, which I am trying to link to (i.e. from their location on the web server) instead of loading the images into the database. However, I cannot find any sample code that seems to work. Two questions: 1. Is this possible (i.e. to store the HYPERLINK to the image in the database , and as the results are returned to the product detail screen, the image file will be displayed)? OR RATHER do I need to store the physical image file in the database location and query it that way? 2. The code sample below contains several lines that show a field populated with text that I am returningthe line under the //Test comment is the field that I'm trying to pull an image back for: printf("REL_PLAN7: %s\n", mysql_result($result,0,"REL_PLAN7")); printf("REL_PLAN8: %s\n", mysql_result($result,0,"REL_PLAN8")); printf("REL_PLAN9: %s\n", mysql_result($result,0,"REL_PLAN9")); //test printf(mysql_result($result,0,FRONT_REND); NOTE: "FRONT_REND" is the name of the database field, and it contains a full web address, not relative. Any help would be GREATLY appreciated. Thanks. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retrieving/Displaying hyperlinked images with PHP
Thanks for the reply. The question is how to pull that hyperlink/file location and display the image file on a PHP page. Basically, the text in the FRONT_REND field is just an image name (1855.jpg), and I store the prefix to that location on the page. I have included all the code from my page belowthe issue at hand is noted by //Problem Area//. Note also, that all fields above this item are simply just retrieving text from a db field not retrieving a file from the db/web server location. Again, thanks for your help. CODE: === \n", mysql_result($result,0,"ID")); printf("HPG_PLAN_ID: %s\n", mysql_result($result,0,"HPG_PLAN_ID")); printf("DESIGNER: %s\n", mysql_result($result,0,"DESIGNER")); printf("PLAN_NAME: %s\n", mysql_result($result,0,"PLAN_NAME")); printf("EXTERIOR: %s\n", mysql_result($result,0,"EXTERIOR")); printf("NUM_BEDROOMS: %s\n", mysql_result($result,0,"NUM_BEDROOMS")); printf("NUM_BATHS: %s\n", mysql_result($result,0,"NUM_BATHS")); printf("NUM_FLOORS: %s\n", mysql_result($result,0,"NUM_FLOORS")); printf("GARAGE: %s\n", mysql_result($result,0,"GARAGE")); printf("NUM_CARS: %s\n", mysql_result($result,0,"NUM_CARS")); printf("FOUNDATION: %s\n", mysql_result($result,0,"FOUNDATION")); printf("MAT_LIST: %s\n", mysql_result($result,0,"MAT_LIST")); printf("COLOR_REND: %s\n", mysql_result($result,0,"COLOR_REND")); printf("PICTURES: %s\n", mysql_result($result,0,"PICTURES")); printf("REPRODUCIBLE: %s\n", mysql_result($result,0,"REPRODUCIBLE")); printf("RR_REVERSE: %s\n", mysql_result($result,0,"RR_REVERSE")); printf("MIRROR_REV: %s\n", mysql_result($result,0,"MIRROR_REV")); printf("CAD_FILES: %s\n", mysql_result($result,0,"CAD_FILES")); printf("BONUS_ROOM: %s\n", mysql_result($result,0,"BONUS_ROOM")); printf("WIDTH: %s\n", mysql_result($result,0,"WIDTH")); printf("DEPTH: %s\n", mysql_result($result,0,"DEPTH")); printf("HEAT_SQ_FT: %s\n", mysql_result($result,0,"HEAT_SQ_FT")); printf("UNHEAT_SQ_FT: %s\n", mysql_result($result,0,"UNHEAT_SQ_FT")); printf("TOTAL_SQ_FT: %s\n", mysql_result($result,0,"TOTAL_SQ_FT")); printf("ROOF_TYPE: %s\n", mysql_result($result,0,"ROOF_TYPE")); printf("ROOF_PITCH: %s\n", mysql_result($result,0,"ROOF_PITCH")); printf("SEC_ROOF_PITCH: %s\n", mysql_result($result,0,"SEC_ROOF_PITCH")); printf("MAIN_CEIL_HEIGHT: %s\n", mysql_result($result,0,"MAIN_CEIL_HEIGHT")); printf("PLAN_DESCRIPTION: %s\n", mysql_result($result,0,"PLAN_DESCRIPTION")); printf("REL_PLAN1: %s\n", mysql_result($result,0,"REL_PLAN1")); printf("REL_PLAN2: %s\n", mysql_result($result,0,"REL_PLAN2")); printf("REL_PLAN3: %s\n", mysql_result($result,0,"REL_PLAN3")); printf("REL_PLAN4: %s\n", mysql_result($result,0,"REL_PLAN4")); printf("REL_PLAN5: %s\n", mysql_result($result,0,"REL_PLAN5")); printf("REL_PLAN6: %s\n", mysql_result($result,0,"REL_PLAN6")); printf("REL_PLAN7: %s\n", mysql_result($result,0,"REL_PLAN7")); printf("REL_PLAN8: %s\n", mysql_result($result,0,"REL_PLAN8")); printf("REL_PLAN9: %s\n", mysql_result($result,0,"REL_PLAN9")); //Problem code // // Then show image and/or details echo "http://www.website.com/images/".$result[FRONT_REND].";>"; //printf("FRONT_REND: %s\n", mysql_result($result,0,'')); printf("REAR_REND: %s\n", mysql_result($result,0,"REAR_REND")); printf("SIDE_REND1: %s\n", mysql_result($result,0,"SIDE_REND1")); printf("SIDE_REND2: %s\n", mysql_result($result,0,"SIDE_REND2")); printf("THMBNAIL_IMG: %s\n", mysql_result($result,0,"THMBNAIL_IMG")); printf("FLRPLAN_1: %s\n", mysql_result($result,0,"FLRPLAN_1")); printf("FLRPLAN_2: %s\n", mysql_result($result,0,"FLRPLAN_2")); printf("FLRPLAN_3: %s\n", mysql_result($result,0,"FLRPLAN_3")); printf("OTHER_IMG1: %s\n", mysql_result($result,0,"OTHER_IMG1")); printf("OTHER_IMG2: %s\n", mysql_result($result,0,"OTHER_IMG2")); printf("NUM_HITS: %s\n", mysql_result($result,0,"NUM_HITS")); printf("PAYPAL_BUTTON: %s\n", mysql_result($result,0,"PAYPAL_BUTTON")); ?> "Miguel Cruz"