Jump to content

HDRebel88

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by HDRebel88

  1. I have a MySQL query that gets data from two tables via a Join query. The resulting dataset is this: See how I have two rows of the title "Coming Out for Christmas". The only difference is the values in the "name" column. I need to essentially use the data from the first "Coming Out for Christmas" row for most of the page and then piece together a comma separated list from the data in the "name" column. So I would get a list like "Test A, Test B". I know I need some kind of PHP flag to do this, but I don't know how or where ... any help? $posterurl="noposter.png"; $titleCheck=null; $cast=null; $connected=Connect(); if($filmsQuery=mysqli_prepare($connected, "SELECT `films`.`title`, `films`.`release`, `films`.`poster`, `films`.`synopsis`, `films`.`status`, `cast`.`name` FROM `films` LEFT JOIN `cast` ON `cast`.`filmID`=`films`.`id`")){ mysqli_stmt_execute($filmsQuery); mysqli_stmt_bind_result($filmsQuery, $title, $release, $poster, $synopsis, $status, $cast); mysqli_stmt_store_result($filmsQuery); $numofFilmsReturned=mysqli_stmt_num_rows($filmsQuery); if($numofFilmsReturned>0){ $i=1; while(mysqli_stmt_fetch($filmsQuery)){ if($titleCheck!=$title){ $titleCheck=$title; $castlist=$cast.", "; $castlist=rtrim($castlist, ","); if($i==$numofFilmsReturned){$filmWrapper='Last';}else{} if($poster==null || $poster==''){$posterurl=$posterurl;}else{$posterurl=$poster;} if($status==0){$status="In Development";}else{$status="Completed";} $releasedate=strtotime($release); $releaseYear=date("Y", $releasedate); $content.='<div id="filmWrapper'.$filmWrapper.'"> <div id="filmTitle"> <div class="filmLeft"><span class="bold">'.$title.'</span><br /><span class="filmStatus">('.$releaseYear.')</span></div> <div class="filmRight"><span class="filmStatus">Status: '.$status.'</span></div> </div> <div id="filmPosterSynopsis"> <div class="filmLeft" id="filmPoster"><img src="'.$posterurl.'" /></div> <div class="filmRight" id="filmSynopsis">Film Synopsis</div> </div> <div id="filmLinksCast"> <div class="filmLeft" id="filmLinks">Website | IMDB | Facebook</div> <div class="filmRight" id="filmCast"><span class="bold">Cast:</span> '.$castlist.'</div> </div> </div>'; $i++; } } } else{ $content.='<div>Could not find any films.</div>'; } } else{ $content.='<div id="queryFailed">Query failed to run correctly.</div>'; } mysqli_close($connected); This is the result right now: http://www.andrewmccarrick.com/kam/?p=films
×
×
  • Create New...

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.