我想在我的表行中放入一个html代码,以便我以后可以选择它。我有变量hstatus1和hstatus2,意思是htmlstatus1和htmlstatus2。如果我填写单词,它的工作,但如果我填写HTML代码,它不起作用。因为我想稍后进行查询选择,我之前从未像这样插入INTO,但我之前可以选择html记录。 TQ
mycode的:
<?php
include("10rbkcon.php"); //connection db
$username2='kampret';
$status1="following";
$status2="follower";
$hstatus1="<font color='black'>following</font>"; //the problem is in here
$hstatus2="<font color='blue'>follower</font>"; //and here
$ssloginmember=$_SESSION[ssloginmember];
$username=$ssloginmember;
mysql_query("INSERT INTO t_follow(username,username2,status,hstatus) VALUES('$username','$username2','$status1','$hstatus1')");
?>
答案 0 :(得分:1)
您是否在尝试将HTML插入数据库之前转义HTML?假设您的HTML存储在变量public class ProductAdapter extends ArrayAdapter<Product> {
ArrayList<Product> productsList;
LayoutInflater vi;
int Resource;
ViewHolder holder;
public ProductAdapter(Context context, int resource, ArrayList<Product> object) {
super(context, resource, object);
vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
productsList = object;
Resource = resource;
// this.context = context;
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
holder = new ViewHolder();
v = vi.inflate(Resource, null);
holder.imageView=(ImageView)v.findViewById(R.id.image_product);
holder.tvId = (TextView)v.findViewById(R.id.product_id);
holder.tvName = (TextView)v.findViewById(R.id.product_name);
holder.tvPrice = (TextView)v.findViewById(R.id.product_price);
holder.tvDiscount = (TextView)v.findViewById(R.id.product_discount);
holder.tvHref = (TextView)v.findViewById(R.id.product_href);
holder.tvRating = (RatingBar)v.findViewById(R.id.rating);
v.setTag(holder);
}
else{
holder = (ViewHolder)v.getTag();
}
new DownlaoadImageTask(holder.imageView).execute(productsList.get(position).getThumb());
holder.tvId.setText(productsList.get(position).getId());
holder.tvName.setText(productsList.get(position).getName());
holder.tvPrice.setText(productsList.get(position).getPrice());
holder.tvDiscount.setText(productsList.get(position).getDiscountprice());
holder.tvHref.setText(productsList.get(position).getHref());
holder.tvRating.setNumStars(Integer.parseInt(productsList.get(position).getRating()));
return v;
}
static class ViewHolder{
public TextView tvId;
public TextView tvName;
public TextView tvPrice;
public TextView tvDiscount;
public TextView tvHref;
public ImageView imageView;
public RatingBar tvRating;
}
private class DownlaoadImageTask extends AsyncTask<String,Void,Bitmap>{
ImageView bmImage;
public DownlaoadImageTask(ImageView bmImage){
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls){
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try{
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (IOException e){
Log.e("Error", e.getMessage());
}
return mIcon11;
}
protected void onPostExecute(Bitmap result){
bmImage.setImageBitmap(result);
}
}
}
,$hstatus1
。
$hstatus2
答案 1 :(得分:1)
$ hstatus1和$ hstatus2的字符串中包含单引号(&#39;),因此当查询运行时,它会获得...following', '<font color='black'>following</font>
,因此来自{{1}的&#39} }。根据{{3}}
color='black'
即可逃脱它们