0

enter image description here

this is my php code..

    <?php

if(!isset($_GET['s'])){
    $s = "Berita";
}else{
    $s = $_GET['s'];
}
if(!isset($_GET['id'])){
    header("Location: content_berita_list");
}else{
    $parent = $_GET['id'];
}

   define('DB_SERVER', 'localhost');
   define('DB_USERNAME', 'manteb_user');
   define('DB_PASSWORD', 'manteb_pass123');
   define('DB_DATABASE', 'manteb_core');
   $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);


$sql2 = "SELECT * FROM manteb_posts WHERE post_type = 'attachment' && post_parent = $parent";
$result2 = $db->query($sql2);

if ($result2->num_rows > 0) {
    // output data of each row
    while($row2 = $result2->fetch_assoc()) {
                $id = $row2['ID'];
                $type = $row2['post_type'];
        $judul = $row2['post_title'];
        $teks = $row2['post_content'];
        $date = $row2['post_date'];
        $gambar = $row2['guid'];
        $parent = $row2['post_parent'];

    }
} else {
    echo "0 results";
}
    ?>
      <html><body><?php echo $gambar; ?></body></html>

this my class

    public class Event implements Serializable {

    public Event(int ID, String post_title, String post_content, String guid, String post_date, String post_parent) {
        this.ID = ID;
        this.post_title = post_title;
        this.post_content = post_content;
        this.guid = guid;
        this.post_date = post_date;
        this.post_parent = post_parent;
    }

    public int ID;
    public String post_title, post_content, guid, post_date, post_parent;

}

and this is my Picasso

public static final String BASE_URL             = "http://manteb.com/";
    public static final String GAMBAR           = BASE_URL + "content_gambar_get.php?id=";


public void onBindViewHolder(EventAdapter.EventViewHolder holder, int position) {
        final Event event = eventlist.get(position);

        String fullUrl = PHPLink.GAMBAR + event.ID;

        Picasso.with(context)
                .load(fullUrl)
                .placeholder(R.drawable.mantebbw)
                .error(android.R.drawable.stat_notify_error)
                .into(holder.image_url);
        holder.txtTitle.setText(event.post_title);
        holder.txtDate.setText(event.post_date);

        holder.image_url.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent in = new Intent(context, EventDetail.class);
                in.putExtra("event", event);
                in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivities(new Intent[]{in});

            }
        });
    }

and i want to take $gambar to place at Picasso load (url) i really confuse cz this database is from wordpress default.. tia

  • what error occured? – Divyesh Patel Feb 10 '17 at 08:10
  • there is no error..its didnt show the immage.. i just beginer and dont know how to parsing the data from the url that in my php to place at picasso load (url).. so this url at picasso is become data from my url like in my post picture.. or this.. manteb.com/android/content_gambar_get.php?id=2039 – Jatra N Hutama Feb 10 '17 at 08:25
  • in my code its didnt show the image cz its just url that to show the image url that i want to show.. tia.. – Jatra N Hutama Feb 10 '17 at 08:27

1 Answers1

0

It didn't show any picture because you just print the URL. Picasso will try to request manteb.com/android/content_gambar.get.php?id=2039 but it gets

<html> 
    <body>
        http://www.manteb.com/wp-content/uploads/2016/05/14edonor4_slo.jpg
    </body>
</html>

Which Picasso have no idea how to convert that into an image. What you can do is to directly show the image whenever you open the content_gambar.get.php. Try using this method

PS: It's better to remove the credentials to your DB when you're using production machine :)

Community
  • 1
  • 1
Ahmad Fadli
  • 894
  • 10
  • 25