如何从数据库中的数据得到的网址,然后将其放置到毕加索负载

问题描述:

enter image description here如何从数据库中的数据得到的网址,然后将其放置到毕加索负载

这是我的PHP代码..

<?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> 

这个班里

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; 

} 

这是我的毕加索

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}); 

      } 
     }); 
    } 

,我想要$ gambar放在毕加索加载(url) 我真的很迷惑cz这个数据库是从wordpress默认.. tia

+0

发生了什么错误删除凭据您的数据库? –

+0

有没有错误..他没有显示immage ..我只是beginer和不知道如何解析从我的PHP放在毕加索加载(网址)的url的数据..所以这个网址在毕加索成为数据从我的网址就像在我的张贴图片..或这.. manteb.com/android/content_gambar_get.php?id=2039 –

+0

在我的代码它没有显示图像cz它只是网址,显示我想要的图像url show .. tia .. –

它没有显示任何图片,因为你只是打印的URL。毕加索将尝试请求manteb.com/android/content_gambar.get.php?id=2039,但它得到

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

毕加索不知道如何将其转换成图像。你可以做的是直接显示图像,只要你打开content_gambar.get.php。尝试使用this method

PS:这是更好,当你正在使用的生产机器:)

+0

ty很多家伙..它的工作很好..需要一两天才能使它工作.. cz我不擅长php .. hehe .. –