将MySQL数据作为图像路径插入

时间:2016-04-19 02:51:20

标签: php mysql

当我尝试做这样的简单代码时,一切正常:

<?php
require 'connect.php';

if($result = $con->query("SELECT * FROM table")) {
    if($row = $result->fetch_object()) {
        echo $row->imgName, ' ',$row->divId, '<br>';
    }
} 
?>

但是由于某种原因,插入图片不起作用:

<?php
require 'connect.php';

if($result = $con->query("SELECT * FROM table")) {
    if($row = $result->fetch_object()) {
        echo "<img src='img/".$row['imgName']."' />";
    }
} 
?>

请帮帮我吧!

1 个答案:

答案 0 :(得分:1)

<asp:GridView ID="gvData" EmptyDataText="There are no data records to display." runat="server" AutoGenerateColumns="false" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White" OnRowDataBound="gvData_RowDataBound" > <RowStyle BorderColor="LightBlue" /> </asp:GridView> protected void Page_Load(object sender, EventArgs e) { foreach (var item in columnNames) { TemplateField tfield = new TemplateField(); tfield.HeaderText = item; gvData.Columns.Add(tfield); } gvData.DataSource = ds.Tables[0]; gvData.DataBind();} protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { for (int i = 3; i < columnNames.Length; i++) { TextboxCount++; TextBox txtName = new TextBox(); txtName.ID = "txt" + Convert.ToString(TextboxCount); txtName.BorderStyle = BorderStyle.None; txtName.Text = (e.Row.DataItem as DataRowView).Row[columnNames[i]].ToString(); e.Row.Cells[i].Controls.Add(txtName); }}} 更改为rcon.eval("system(\"echo $$\", intern = TRUE)");