General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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 July 15th, 2003, 03:06 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 16
"IF" Statement

I've been trying to display other text if the row in a table is empty.
This page is coming from another script, say siteDetails.php?id=11

Here's what I have so far,


PHP Code:
 dataBase
  
id int(11NOT NULL auto_increment,
  
name varchar(255NOT NULL default '',
  
email varchar(255NOT NULL default '',
  
urlLink varchar(100NOT NULL default '',
  
urlName varchar(255NOT NULL default '',

// dB Connection
$connection mysql_connect($hostTypeect...
// Query for info
$query "SELECT * FROM $tableName WHERE id = '$id'";

$result mysql_query($query) or die ("Error in query: $query. " mysql_error());
$row mysql_fetch_object($result);
if (
$row)
{

// Displaying the results
User: <a href="<? echo $row->email; ?>"><? echo $row->name?></a>

<?
if (empty($ScrUrl)) {
    print (
"No URL Provided");
} else {
    print (
"Source: <a href=\" $row->ScrUrl \"> $row->ScrName </a>");
}
?>

I have also tried this...

<?
if (empty ($ScrUrl) == TRUE) {     
    print 
" No Url Provided";
} else {
    print 
" Source: <a href=\" $row->ScrUrl; \"> $row->ScrName </a> ";
}
?>

Both statements above print "No Url Provided", 
Even if there is a url and a name in those tables. 

Everything else works, with no errors. 

Reply With Quote
  #2  
Old July 15th, 2003, 03:12 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 16
Sorry, I got it right after I posted this...

PHP Code:
<?
if (empty ($ScrUrl) == TRUE) {     
    print 
" No Url Provided";
} else {
    print 
" Source: <a href=\" $row->ScrUrl; \"> $row->ScrName </a> ";
}
?>

I changed $ScrUrl to $row->ScrUrl , like I did on all the others.

<?
if (empty ($row->ScrUrl) == TRUE) {     
    print 
" No Url Provided";
} else {
    print 
" Source: <a href=\" $row->ScrUrl; \"> $row->ScrName </a> ";
}
?>


anyways, thanks all

Reply With Quote
  #3  
Old July 16th, 2003, 12:11 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Gratz to you too I love it when people figure things out..

Isn't it an ego booster?

Reply With Quote
  #4  
Old July 16th, 2003, 02:01 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 16
I agree, nicat23
I had to stand up and do a dance, after I saw what was going on.

egoBoost inDeed!

Reply With Quote
  #5  
Old July 16th, 2003, 08:31 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 16
Well - lets rewind a little:
PHP Code:
if (empty ($row->ScrUrl) == TRUE

No need for any of that. To correct the above, it would be:
PHP Code:
if ( empty( $row->ScrUrl ) ) 

Now, you don't even need that - you can use a boolean check on that column:
PHP Code:
if ( ( bool )$row->ScrUrl )
{
      
/* empty */
}
else
{
      
/* not empty */

__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #6  
Old July 16th, 2003, 10:22 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 16
Thanks jpenn,
I'll also try that method, just for my reference.

To me, It looks more simplified.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > "IF" Statement


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap