Jump to content

Archived

This topic is now archived and is closed to further replies.

Incessant-Logic

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

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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'];
}
?>

 

 

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.