pdo - hide my div in php if jobs = 1 -
i trying hide div, if info = 1
here had b4
$sql = 'select id, start, work_id, nummer, left(job_art, 30) job_art godkend work_id = :work_id'; $q = $pdo->prepare($sql); $q->bindvalue(':work_id', $work_id); $q->execute(); $q->setfetchmode(pdo::fetch_assoc); ?> <?php while ($r = $q->fetch()): ?> <div class="liste"> <?php if ($r["info"] == 1){ echo'' ; } else { echo '<a href="visweb_godkend.php?work_id='.$r["work_id"]. '&id='.$r["id"]. '&nummer='.$r["nummer"].' " class="bluelink"><p class="padding"><span class="blacklink">'.$r["nummer"]. '</span> '.$r["job_art"]. '</p></a>'; } ?> </div> <?php endwhile; ?> <div class="buttomcorners"></div>
so i´m trying inside php, while fetch gives me problems.
$sql = 'select id, start, work_id, info, nummer, left(job_art, 30) job_art rum work_id = :work_id'; $q = $pdo->prepare($sql); $q->bindvalue(':work_id', $work_id); $q->execute(); $q->setfetchmode(pdo::fetch_assoc); if ($r["info"] == 1){ echo ''; } else { echo '<div class="topcorners"></div>'; while ($r = $q->fetch()): echo '<div class="liste">'; echo '<a href="visweb_opgaver.php?work_id='.$r["work_id"]. '&id='.$r["id"]. '&nummer='.$r["nummer"].' " class="bluelink"><p class="padding"><span class="blacklink">'.$r["nummer"]. '</span> '.$r["job_art"]. '</p></a></div> '; endwhile; echo '<div class="buttomcorners"></div>'; } ?>
in code above, had move while fetch, if put while fetch else, design not right, , because had move it, if info = 1 dont work.
i trying this
top div
post 1
post 2
post 3
and on
botton div
but if there post info = 1, nothing should showen.
$sql = 'select id, start, work_id, nummer, left(job_art, 30) job_art godkend work_id = :work_id'; $q = $pdo->prepare($sql); $q->bindvalue(':work_id', $work_id); $q->execute(); $q->setfetchmode(pdo::fetch_assoc); //check have results if($q->rowcount() > 0){ echo '<div class="topcorners"></div>'; while ($r = $q->fetch()){ if ($r["info"] != 1){ echo '<div class="liste">' echo '<a href="visweb_godkend.php?work_id='.$r["work_id"]. '&id='.$r["id"]. '&nummer='.$r["nummer"].' " class="bluelink"><p class="padding"><span class="blacklink">'.$r["nummer"]. '</span> '.$r["job_art"]. '</p></a>'; echo '</div>'; } } echo '<div class="buttomcorners"></div>'; }
Comments
Post a Comment