从mysql数据库添加图像src

时间:2017-12-05 10:57:17

标签: php mysql

我的问题是为什么我的php页面上没有显示图片,我在图像库中有图像网址' imageurl'。我想回显url图像src,这将显示文件夹中的图片。错误是Parse错误:语法错误,意外'<'在....第95行。我也将第95行放在示例代码中。

runApp(list(
  ui = shinyUI( fluidPage(

sidebarLayout( 
  sidebarPanel(
    conditionalPanel(condition="input.conditioned == 0",helpText("This is navnarMenu 0")),
    conditionalPanel(condition="input.conditioned == 1",helpText("This is navnarMenu 1")),
    conditionalPanel(condition= "input.Guidelines == 2.1 && input.conditioned == 2",helpText("This is navnarMenu 2")),
    conditionalPanel(condition= "input.Guidelines == 2.2 && input.conditioned == 2",helpText("This is navnarMenu 3"))),

  mainPanel(tabsetPanel(id='conditioned',

                        tabPanel("About", value=0),                   

                        tabPanel("Tab 1",value=1,tabsetPanel(
                          tabPanel("Tab 1.1"),
                          tabPanel("Tab 1.2", tabsetPanel(
                            tabPanel("Tab 1.2.1"),
                            tabPanel("Tab 1.2.2"))))),

tabPanel("Guidelines",value = 2, tabsetPanel( id = "Guidelines",         
                   navbarMenu("Tab 2.1",
                                   tabPanel("Tab 2.1.1",value=2.1),
                                   tabPanel("Tab 2.1.2",value=2.1)),

                 navbarMenu("Tab 2.2",
                                   tabPanel("Tab 2.2.1",value=2.2),
                                   tabPanel("Tab 2.2.2",value=2.2))))

  ))))),

server = function(input, output, session) {}


))

3 个答案:

答案 0 :(得分:0)

需要在第95行打开和关闭php标签

所以, 像这样更改您的else部分:

else{ ?>
      <img src="<?php echo $row['imageurl'];?>" width='300' height='300'/>
<?php    }

答案 1 :(得分:0)

您忘记在elseif子句后打印结果。此外,你应该在PHP模板中use alternative syntax,它会使事情更容易阅读/维护(你是为while / endwhile做的)。

<?php while($row = mysql_fetch_assoc($query)): ?>
 <div class="NewsItem">
    <div>
      <h1><?php echo $row['txt']; ?></a> <br>
      <span>posted on <?php echo $row['added']; ?></span><span> by <?php echo $row['adder'];?></span>

     </div>
     <div class="imgdiv">
    <?php if(($row['imageurl'] == 'NULL') or ($row['imageurl']== '')): ?>
        No image
    <?php else: ?>
        <img src="<?php echo $row['imageurl'];?>" width='300' height='300'/>
    <?php endif; ?>
    </div>
     <br>
     <div>
     <form action="comment.php"method="post" name="addComment"><input type="text" placeholder="kommentaar" name="commenttext" maxlenght="100"><input type="submit" name="addComment" value="Lisa kommentaar">
     <input id="prodId3" name="prodId3" type="hidden" value="<?php echo $row['id']; ?>">
     </form>
     </div>
  </div>

<?php endwhile; ?>

答案 2 :(得分:0)

在你的代码中有打开和关闭php标签的错配,也把图像的完整URL与站点URL放在一起 请尝试以下代码

else{ ?>
      <img src="<?php echo "your site url".$row['imageurl'];?>" width='300' height='300'/>
<?php    }
相关问题