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:
  #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: 8
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: 8
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: 8
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: 8
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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek