Welcome Guest, Not a member yet? Register   Sign In
Simple query left join question - MVC
#1

[eluser]Otemu[/eluser]
Hi,

Another simple question that I be grateful if anyone can respond. I have a left join query for my news index page, which basically lists various news stories(image, title and intro text), clicking on either the image or title takes you to the corresponding page with the full story.

Not all the time however a image is return, as its not a mandatory requirement, so I plan to have a default picture displayed. Currently I have a switch statement on the actual view checking this as shown below:

Code:
<?php
    foreach($newsListAll as $row){
    // if no image available issue...............
        switch ($row['imageurl']){
            case "":
                echo "<li>No Image Available</li>";
                break;                        
            default:
                echo "<li><a href='".base_url()."index.php/home/news/".$row['><img src='".base_url().$row[' alt='".$row[' /><a></li>";
                break;
        }
        echo "<li>".anchor('home/news'."/".$row['newsid']."/".$row['page_url'],$row['page_title'])."</li>";
    }
?&gt;

Wasn't sure if this was correct MVC practice to be checking this in the view, or if this should be handled on the actual controller or even the model itself.

Cheers


Messages In This Thread
Simple query left join question - MVC - by El Forum - 11-16-2010, 03:23 AM
Simple query left join question - MVC - by El Forum - 11-16-2010, 05:46 AM
Simple query left join question - MVC - by El Forum - 11-17-2010, 12:56 AM
Simple query left join question - MVC - by El Forum - 11-17-2010, 08:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB