mysql - Why Is My Variable Not Working As A Parameter In PHP Funtion -
at top of document created varible called $selectedid using $_get id of selected user(ill later switch encrypted string) url looks little profile.php?id=4. have function loops though database blog post same number $selectedid variable, inputted second parameter of function.
the issue second parameter in function $selectedid supposed used number filter while looping through database, seems variable not being inserted function therefore loop not working properly
this main page showing information
<div id="blogfeed"> <ul> <!-- exicute fucntion functions.inc.php grabs feed articles database --> <?php $_result = display_blogs_profile($connect, $selectedid); // count how many rows in database $limit = count($_result); // loop through articles(rows) database for($i = 0; $i < $limit; $i++){ // define varibles each column $id = $_result[$i][6]; $title = $_result[$i][0]; $date = $_result[$i][1]; $article = $_result[$i][2]; $photo = $_result[$i][3]; $icon = $_result[$i][4]; $author = $_result[$i][5]; $findauthor = $_result[$i][7]; $feedradius = "50px"; $iconphoto = "newsred.png"; $photo = $_result[$i][3]; $feedradius = "0px"; $contentlink = "read more"; $realignicon = 'margin-right: -195px;'; // show first 10 articles stop building html if((string)$employeeid != $findauthor){ continue; }else{ ?> <li> <div class="eventboximage" style="background: url('images/<?php echo $photo ?>'); background-size: cover; background-position: center; border-radius: 50px"></div> <div class="eventcontentcontainer"> <h1><?php echo $title; ?></h1> <h4>posted by: <?php echo $author; ?></h4> <h5><?php echo $date ?></h5> <p><?php echo $article ?></p> <h6><a href="blog.php?id=<?php echo $id; ?>"><?php echo $contentlink ?></a></h6> <span style="background: url('images/<?php echo $iconphoto ?>') no-repeat; <?php echo $realignicon; ?> background-size: 45px;"><a href="#"></a></span> </div> </li> <?php }}?> <!-- close php loop --> </ul> </div> <div id="blogpostcontainer"> <h1 class="blog">create blog post</h1> <form class="blog" action="includes/insert.php" method="post"> <input name="blogtitle" type="text" placeholder="enter blog title" required/> <input name="blogarticle" type="textbox" placeholder="enter blog post" required/> <input name="blogsubmit" type="submit" value="submit" /> </form> </div> <div id="profilesearch"> <div id="searchbar"> <form id="search" action="index.php" method="post"> <div id="searchicon"></div> <input type="search" name="search" placeholder="search through <?php echo $firstname ?>'s posts" onkeyup="searchq();" /> <input type="hidden" name="editid" id="editid" value="<?php echo $employeeid ?>" /> <div id="userresults"> </div> </form> </div> </div> </div>
and here function
function display_blogs_profile($connect, $selectid) { $sql = "select * intranet"; $query = mysqli_query($connect, $sql); $finalarray = array(); $i = 0; while ($row = mysqli_fetch_assoc($query)) { $id = $selectid; $title = $row['title']; $date = $row['date']; $article = $row['article']; $photo = $row['photo']; $icon = $row['icon']; $authorid = $row['findauthor']; $author = $row['author']; if($row['icon'] === "3" && $authorid === $selectid){ $finalarray[$i] = array($title, $date, $article, $photo, $icon, $author, $id, $authorid); } $i++; } $finalarraydesc = array_reverse($finalarray); return $finalarraydesc; }
got it! help! if statement , if $employeeid != $findauthor statement break or continue loop no matter unless on own account. had take $employeeid != $findauthor statement out :)
Comments
Post a Comment