SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old August 16th, 2004, 03:08 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
problem with img src and php

I am able to display row to call image from file, but I want to enclose the html call (img src) in php so I can run an if statement. Now, if there is no image, the field is empty on the page, displays a ?. But, I want to run an if statement to check first, then print the img src. , if not, print "".

Here is the script to just print the image anyway.
I am happy with the way the size feature works. The database has a field for tall or wide from radio button. It has a set size, but it will display it as tall or wide. Little gains.

PHP Code:
<img src="../uploads/<?php
 print $foldername; ?>/<?php $query = "
SELECT FROM teachpo WHERE teacher '".$foldername."' and id $id";
$result = @mysql_query($query, $connection) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$photo1 = stripslashes($row['photo1']);
}
 print $photo1; ?>"  
<?php 
 $query 
"SELECT * FROM teachpo WHERE teacher = '".$foldername."' and id = $id";
$result = @mysql_query($query$connection) or die(mysql_error());
while (
$row mysql_fetch_assoc($result)) {
 
$photo1size stripslashes($row['photo1size']);
 }
 if (
$photo1size != "yes") { $photosize1 "width=\"270\" height=\"180\"";} else {$photosize1 "width=\"180\" height=\"270\"";}
 
  print 
$photosize1?>  border="1" align="middle" hspace="5" vspace="5" > 


Later I'd like to give user the option to size it with form, but this is easy for now.

One more question, I used the following code to create the radio buttons and it is not returning the button as marked when I edit a record... any ideas?

PHP Code:
<p>Photo is Tall? <input type="radio" name="photo1size" value="yes" <?php if($photo1size == "yes") echo "selected=selected"?>/>        Or is Photo Wide? 
                        <input type="radio" name="photo1size" value="no" <?php if($photo1size == "no") echo "selected=selected"?>/> 


Thanks everyone for all the help.
__________________
bow wow!

Reply With Quote
  #2  
Old August 16th, 2004, 03:55 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Before you print anything (or display the beginning of the img tag outside PHP), you need to check to see if the image field has a value. If it does, then start printing the image and building up the parameters. Else, just keep on trucking without printing anything.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old August 17th, 2004, 01:17 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Yes, but..

Thank you for your help dh, but I don't get how to skip the img html tag with php, since the img src tag is html. It it was enclosed in php then I could see how to if else it.

I'll keep playing with it.

Thanks again.


What I'm trying to learn is how to make the <img src> tag a variable with php, but when I write to put in $img1 = "<img src ... etc. then it doesn't work. I'm missing a / or . or ./" , I'm still trying to learn that part.

R.

Reply With Quote
  #4  
Old August 17th, 2004, 02:06 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
What I'm suggesting is that you move it into PHP rather than having it be in HTML. Just move the "<img src='uploads/" inside the PHP block and print it out. Same with the end of the tag. If you're missing a /, just add one in the print statement where it's missing. If you put the img tag in the HTML, then the HTML's always going to try to display an image; the only way to test for an image before displaying it is to move the whole image tag inside a conditional statement in PHP.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > problem with img src and php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway