0

Hi, I'm trying to make a website in which users can post thing. The thing is, is that if it is a photo then I want it to show as a photo. Unfortunately, if the first row in the database that matches my query, all the posts will be echod out as images, which of course doesn't work. I want to run this code for each individual post. iframe works for the comments in my website, but not to check wheter it is a photo or not. So basically it doesn't check whether it is a post for the specific post-it checks if the first row is a photo or not. Code

  $posts = mysqli_query($link, "SELECT content,id, Posted_By,Date,type FROM wgo WHERE Posted_By='$channel_name' OR Posted_By='$user' ORDER BY id DESC ");

    while($row = mysqli_fetch_array($posts)) {
    $channel_name2 = $row['content'];
    $channel_name3 = $row['Posted_By'];
    $channel_name4 = $row['Date'];
    $channel_name5 = $row['id'];
    $channel_name6 = $row['type'];

    if ($channel_name6 = 'post') {
    $channel_name2 = $channel_name2;
    }
    else {
    $channel_name2 =  "<img src='/videobox/data/uploads/images/$channel_name2' height='200px' width='100px'>";
    }






echo "$channel_name2";?>

Btw I cut out some code

Edited by Jibran12345: MOre details and better question

5
Contributors
5
Replies
35
Views
3 Years
Discussion Span
Last Post by Josh Connerty
0

Not sure I understand perfectly, but in your WHILE loop you can just check if it's a picture by using some kind of post type field?
For example have a post type field that says "image|post|xyz" and then test for them in a SWITCH or something.

1

Try the following:

 $go=true
 while($row = mysqli_fetch_array($posts)) {
    $channel_name2 = $row['content'];
    $channel_name3 = $row['Posted_By'];
    $channel_name4 = $row['Date'];
    $channel_name5 = $row['id'];
    $channel_name6 = $row['type'];
    if ($go==true) {
      if ($channel_name6 = 'post') {
          $channel_name2 = $channel_name2;
        } else {
          $channel_name2 =  "<img src='/videobox/data/uploads/images/$channel_name2' height='200px' width='100px'>";
        }
    $go=false;
    } else {
    echo $channel_name2;
    }
 }
Votes + Comments
thanks for your help, but I fixed it differently :D
0

Thanks! But I fixed it by putting the code in a different place. Thanks though I appreciate it !

0
if ($channel_name6 = 'post') {
    $channel_name2 = $channel_name2;
} else {
    $channel_name2 =  "<img src='/videobox/data/uploads/images/$channel_name2' height='200px' width='100px'>";
}

Correct me if I'm wrong but are you not trying to see if $channel_name6 is equal to "post" and not set the value of it to "post"? If so then you need a double equals == not a single =.

Edited by Josh Connerty

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.