English 中文(简体)
是否在回合中? 还是有更好的办法?
原标题:isset within an echo? Or is there a better way?
$sql = "SELECT * from post where forum_id = $_GET[id]";
    $result = mysqli_query($conn, $sql) or die( Error querying database. );     
    while ($row = mysqli_fetch_array($result)) {
        echo    . $row[ fourm_id ]; 
        echo  <div id="post3">
            <p class="1">
            <span class="name"> . 
              .$row[ name ].  </span> .
             <span class="trip">
              .  ! 
            . $row[ title ].  .
              </span> .
              <span class="time">
              .$row[ time ].    . 
              </span> .
              </p>
            <p class="2">
            <span class="texts">
              .$row[ texts ].    .
              </span> .
              </p> .
            if (!isset($_SESSION["user_id"])) { 
            }
             else {
              <a href="delete_post.php?fourm_id=  . $row[ id ].  >Delete</a>  . }
              </div> ;
         } 
        mysqli_close($conn);

?>

守则中的错误是显而易见的,只是表明了我试图做些什么。

反应 我在这里展示了用户员额,我会如何坚持在那里的僵局,这样,只有行政部门才能看到删除链接? 或者,在用户员额之外,还有另一种方式这样做?

最佳回答
<?
$data = array();
$sql  = "SELECT * from post where forum_id = ".intval($_GET[ id ]);
$res  = mysqli_query($conn, $sql) or trigger_error(mysqli_error($conn));
while ($row = mysqli_fetch_array($result)) {
  $data[] = $row;
}
?>
<?php foreach($data as $row): ?>
<?=$row[ fourm_id ]?>
<div id="post3">
  <p class="1">
    <span class="name"><?=$row[ name ]?></span>
    <span class="trip"> !<?=$row[ title ]?></span>
    <span class="time"><?=$row[ time ]?></span>
  </p>
  <p class="2">
    <span class="texts"><?=$row[ texts ]?></span>
  </p>
<?     if (isset($_SESSION["user_id"])): ?>
  <a href="delete_post.php?fourm_id=<?=$row[ id ]?>">Delete</a>
<?     endif ?>
</div>
<? endforeach ?>
问题回答

如果你想在线这样做,你可以使用ternary营运人,或像

三级操作员(如果只有几处插入物的话):

echo "Foo ".(isset($bar) ? "bar" : "");

http://www.un.org/Depts/DGACM/index_french.htm

printf("Foo %s", isset($bar) ? "bar" : "");

然而,这并不大,因此,如果你拥有大规模的“建筑”,那么把产出分成不止一个报表会非常缓慢:

echo "Foo ";
if (isset($bar)) {
    echo "bar";
}

如果你有很多人要入住,这是最好的。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签