Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 6th, 2008, 03:18 AM
Registered User
 
Join Date: Jan 2008
Location: Grefrath, , Germany.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gabstlee
Default PHP-SQL

Hi,
I have a script with title(In html code) and sql queries in a table which works but my problem is "When the query has non results from the DB, the title appears without any results. I would like to have a script which writes a title only when there is a result in the DB.
(Code with Table Field title and result)

gabby
  #2 (permalink)  
Old January 8th, 2008, 07:48 PM
Authorized User
 
Join Date: Sep 2007
Location: , , .
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can try checking for nothing with
Code:
if(trim($variable) !=''){
//do title stuff
}
or check the number of rows returned
Code:
$query = mysql_query("select * from table");
if(mysql_num_rows($query) > 0){
//do title stuff
}

http://mynameissteve.com
  #3 (permalink)  
Old January 11th, 2008, 12:45 AM
Registered User
 
Join Date: Jan 2008
Location: Grefrath, , Germany.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gabstlee
Default

Thank you steve. I will try it today and inform you

gabby


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP + My sql jayarajin2k3 JSP Basics 0 April 10th, 2007 12:55 AM
PHP and SQL orders Ashleek007 PHP How-To 2 November 7th, 2004 08:27 AM
Php with SQL Yee PHP Databases 3 November 1st, 2004 03:09 PM
PHP and SQL (NOT MYSQL) garethjennings PHP Databases 1 July 21st, 2004 04:14 AM
Speed up executing SQL in PHP stash PHP Databases 5 April 15th, 2004 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.