29, May 2012

When calling a Mysql DB field that is empty display a image - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: When calling a Mysql DB field that is empty display a image
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: When calling a Mysql DB field that is empty display a image  (Read 2745 times)
I love Pokemon
*
Gender: Male
Posts: 14
102 credits
Members referred : 0


« on: Oct 29, 2008, 03:13:33 pm »

Hiya
Just got a little daft problem and my brain has went a bit dead {totaly)

I am creating a simple content management syistem that can be managed and edited directly from the admins pc
without having to use the  pages online admin pages on the remote server
using MS access or open office however i did run into a few minor probs with open office

To get round the oppen office probs I am creating some scripts so that I can manage my remote
website from my local server, All apears to be working just about ok

The test site can be found here its a simple image gallery based on the script but can easly adapted for classifides, blog etc
that can be remotaly managed

http://juraphotos.photofxr.co.uk/gallery/
______________________________________________________
If their is no image name stored in the DB table I would like to display a small logo


The image name  is stored in the database
and is called to the page with
$query_rs_page_template = "SELECT * FROM webpages WHERE number = '$page_id'";

<img src="../images/<?php echo $row_rs_page_template['urlmainimg']; ?>.jpg" />

A simple if and else statement but as they say I carnt see the wood for the trees lol
any sergestions would be most apreciated
___________________________________________
The script is to be  opensource [b][/b]
To do docs and clean up the junk
I shall upload the full script later tonight or tomorow to my server with a few notes
Many thanks
Juraphotos
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Oct 29, 2008, 03:17:08 pm »

I am not sure if this is what you ask but I will give it a try Smiley

<img src="../images/<?php echo empty($row_rs_page_template['urlmainimg']) ? 'imageDoesNotExists.gif' : $row_rs_page_template['urlmainimg']; ?>.jpg" />
?>

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Oct 29, 2008, 07:23:08 pm »

a better way is to test the image url with file_exists and if not show the default image

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Oct 29, 2008, 07:29:28 pm »

a better way is to test the image url with file_exists and if not show the default image

You are right that's better because it prevents you from bad inserted data too.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Oct 29, 2008, 07:32:29 pm »

or a missing / bad image

I love Pokemon
*
Gender: Male
Posts: 14
102 credits
Members referred : 0


« Reply #5 on: Oct 29, 2008, 10:58:11 pm »

Thanks for the help I have just being looking on php.net at the

if (file_exists( ))

should do the job fine, I should have thought of that must have being looking at code to long and brain got waterloged thanks

Also out of intrest which WYSIWYG editor you use on this forum
I am at pressent using the fckeditor on the remote admin server and the portable remote admin server on the usb stik

I was wondering if you had any recomendations for a WYSIWYG editor that did not use much resorces
The fckeditor is very good but can be a little slow to load

Many thanks
Juraphotos
Much apreciated
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #6 on: Oct 29, 2008, 11:16:23 pm »

fckeditor is just fine. Here we are not using a WYSIWYG editor. Forum editors use BBcode not native html so it wont help you anyway

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Oct 30, 2008, 06:44:58 am »

forget fuckeditor and use tinymce, all bigger CMS systems using tinymce. fckeditor creates terrible html code

I love Pokemon
*
Gender: Male
Posts: 14
102 credits
Members referred : 0


« Reply #8 on: Oct 31, 2008, 12:35:19 pm »

Thanks for the advice Lastnight I setup tinymce all is working fine The fck editor worked fine just slow
but will take your advice on the messy code also i noticed tinymce was nice and easy intergrate into the
pages

I am going to have a look at the tinymce  php compressor to see if it can speed up loading
The final scripts are almost done just have to check things through, and tidyup the code and get rid of the junk

Many Thanks much apreciated

Juraphotos
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Oct 31, 2008, 01:10:19 pm »


I love Pokemon
*
Gender: Male
Posts: 14
102 credits
Members referred : 0


« Reply #10 on: Nov 06, 2008, 02:33:45 am »

Thanks for the link to the tutorial tinymce was easy to setup without any problems nice and easy I have also intergrated ibrowser and imanager
The link to the download page for ibrowser and imanager is

http://j-cons.com/downloads/

it might be usefull to other users as they are a free alternative to tinymce,s MCFileManager and MCImageManager

The cms is coming along fine I am adding some security to the admin pages,

though the cms syistem is intended to be managed remotly using Ms access or using the scripts i have made that run from a server running on a local pc or the portable server on the usb stik

I thought id better add this incase any users of the script have problems conecting directly to their remote mysql database from their pc and have to edit their site via their web browser

Also have to do some basic template examples,  documents and setup instructions
Many thanks for your help and i will keep you updated

Juraphotos
Novice Spammer
***
Posts: 101
606 credits
Members referred : 0


« Reply #11 on: Nov 27, 2008, 06:27:43 pm »

I am not sure if this is what you ask but I will give it a try Smiley

<img src="../images/<?php echo empty($row_rs_page_template['urlmainimg']) ? 'imageDoesNotExists.gif' : $row_rs_page_template['urlmainimg']; ?>.jpg" />
?>


Thanks a lot. It's very useful for me
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=8145
Tags : mysql server inages if else statement empty cms gallery remote admin management dat Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: When calling a Mysql DB field that is empty display a image
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 29, 2012, 12:45:53 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.