Jump to content


Photo

If value is blank show this record, if thats blank show nothing


  • Please log in to reply
1 reply to this topic

#1 Incessant-Logic

Incessant-Logic
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 14 January 2006 - 11:40 PM

Using DW8, MySQL and PHP:

I'm extracting three parts of a recordset.

$row_query_fiction['fiction_title'] (story)
$row_query_fiction['chapter_no'] (nothing)
$row_query_fiction['chapter_title'] (A good start)

I want to display the title folloed by the name of the chapter, then if thats empty by the chapter number and if thats empty nothing.
    <?php if {
$row_query_fiction['chapter_title'] == "" {
if $row_query_fiction['chapter_no'] == "" {}
    else {echo ': Chapter ', $row_query_fiction['chapter_no'];}
    else {echo ': ', $row_query_fiction['chapter_title'];}
} ?>

Would output:
Story: A good start.

But all I get is Parse error: parse error, expecting `'('' in D:\http\ilweb-v\fiction.php on line 126 (which is first line)

What am I doing wrong?

#2 degsy

degsy
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 17 January 2006 - 02:24 PM

You seem to be mixed up with your brackets and order of if statements.

You could use something like




<?php
 if($row_query_fiction['chapter_title'] != ""){
  echo ': ' . $row_query_fiction['chapter_title'];
 }
 if($row_query_fiction['chapter_no'] != ""){
  echo ': Chapter ' . $row_query_fiction['chapter_no'];
 }
?>







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users