Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在href中插入php变量以从该变量的检索结果创建链接? 我的网站_Php_Mysql_Variables_Href - Fatal编程技术网

如何在href中插入php变量以从该变量的检索结果创建链接? 我的网站

如何在href中插入php变量以从该变量的检索结果创建链接? 我的网站,php,mysql,variables,href,Php,Mysql,Variables,Href,查看$outputListdata1中的第14行,其中$title位于href: 我想在href中插入一个$label变量来代替#。因此,它应该显示数据库中变量的结果 例如: 如果我的数据库有$label变量的结果是karthik,那么它应该是这样的(假设变量$title的结果是堆栈溢出的风扇) 我知道我的问题可能很简单,也可能很难回答,但我100%相信你们会给出答案的。提前谢谢 (注意:这是我的第二个问题,请原谅我的提问方法很笨拙)您可以用HTML编写php,使用echo命令可以将变量/

查看$outputListdata1中的第14行,其中$title位于href:

我想在href中插入一个$label变量来代替#。因此,它应该显示数据库中变量的结果

例如:

如果我的数据库有$label变量的结果是karthik,那么它应该是这样的(假设变量$title的结果是堆栈溢出的风扇)

我知道我的问题可能很简单,也可能很难回答,但我100%相信你们会给出答案的。提前谢谢


(注意:这是我的第二个问题,请原谅我的提问方法很笨拙)

您可以用HTML编写php,使用echo命令可以将变量/字符串输出到HTML中,并发送给用户


您可以使用HTML编写php,使用echo命令,您可以将变量/字符串输出到HTML中,并发送给用户


只需在属性中插入$Label变量:

<?php
mysql_connect("localhost","username","password") or die (mysql_error());
mysql_select_db("databasename") or die (mysql_error());

$sqlmydata = mysql_query("SELECT id, label, title, info, body FROM table LIMIT 0,10");

// Build the Output Section Here
$outputListdata1 = '';
while($row = mysql_fetch_array($sqldata)){ 

    $id = $row["id"];
    $label = $row["label"];
    $title = $row["title"];
    $info = $row["info"];
    $body = $row["body"];

    $outputListdata1 .= '<div class="content1">
                    <a href= "#" >' .$title. '</a>
                    </div><!-- end of content1 -->

                    <div class="content2">
                    ' .$info. '
                    </div><!-- end of content2 -->';
} // close while loop
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>my site</title>

    </head>

    <body>

    <div class="container">
        <?php print "$outputListdata1"; ?> 
    </div><!-- end of container -->

</body>
</html>


您应该学习PHP的基础知识,也许可以做如下教程:。

只需在属性中插入$Label变量:

<?php
mysql_connect("localhost","username","password") or die (mysql_error());
mysql_select_db("databasename") or die (mysql_error());

$sqlmydata = mysql_query("SELECT id, label, title, info, body FROM table LIMIT 0,10");

// Build the Output Section Here
$outputListdata1 = '';
while($row = mysql_fetch_array($sqldata)){ 

    $id = $row["id"];
    $label = $row["label"];
    $title = $row["title"];
    $info = $row["info"];
    $body = $row["body"];

    $outputListdata1 .= '<div class="content1">
                    <a href= "#" >' .$title. '</a>
                    </div><!-- end of content1 -->

                    <div class="content2">
                    ' .$info. '
                    </div><!-- end of content2 -->';
} // close while loop
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>my site</title>

    </head>

    <body>

    <div class="container">
        <?php print "$outputListdata1"; ?> 
    </div><!-- end of container -->

</body>
</html>


您应该学习PHP的基础知识,也许可以做如下教程:。

它不起作用,因为您用一个引号封装了变量。使用双引号检索变量的值,而不是文字变量文本

<?php 

$outputListdata1 .= '<div class="content1">
                     <a href= "' .$label. '" >' .$title. '</a>
                     </div><!-- end of content1 -->
                     <div class="content2">' .$info. '</div><!-- end of content2 -->';

?>
$outputListdata1.=“$info”;

它不起作用,因为您用一个引号封装了变量。使用双引号检索变量的值,而不是文字变量文本

<?php 

$outputListdata1 .= '<div class="content1">
                     <a href= "' .$label. '" >' .$title. '</a>
                     </div><!-- end of content1 -->
                     <div class="content2">' .$info. '</div><!-- end of content2 -->';

?>
$outputListdata1.=“$info”;

使用它的方式与使用$title相同:

$outputListdata1 .= "<div class='content1'><a href='$label'>$title</a></div><div class='content2'>$info</div>";
$outputListdata1.='
“.$info”
';

使用它的方式与使用$title相同:

$outputListdata1 .= "<div class='content1'><a href='$label'>$title</a></div><div class='content2'>$info</div>";
$outputListdata1.='
“.$info”
';

只需将该行代码粘贴到第14行,这将对您有效;)


只需将该行代码粘贴到第14行,这将对您有效;)


我的网站

我的网站

我只是把这个链接放在

<?php mysql_connect("localhost","username","password") or die (mysql_error()); 
mysql_select_db("databasename") or die (mysql_error()); 
$sqlmydata = mysql_query("SELECT id, label, title, info, body FROM table LIMIT 0,10");  // Build the Output Section Here 
$outputListdata1 = ''; 
while($row = mysql_fetch_array($sqldata))
{      
  $id = $row["id"];    
  $label = $row["label"];    
  $title = $row["title"];    
  $info = $row["info"]; 
} // close while loop 
?> 
<!DOCTYPE html> 
<html>    
<head>  
  <meta charset="UTF-8"> 
  <title>my site</title> 
</head>  
<body>     
  <div class="container">    
    <div class="content1">    
      <a href= "#" ><?php echo $title;?></a>    
    </div><!-- end of content1 -->               
    <div class="content2">          
      <?php echo $info;?>          
    </div>    
  </div><!-- end of container --> 
</body>
</html>
然后使用

$SomeLink="index.php";
echo“$nam找不到您的密码


";

在IE、Edge和Google Chrome的两端加上双引号,我只是把链接放在类似的地方

<?php mysql_connect("localhost","username","password") or die (mysql_error()); 
mysql_select_db("databasename") or die (mysql_error()); 
$sqlmydata = mysql_query("SELECT id, label, title, info, body FROM table LIMIT 0,10");  // Build the Output Section Here 
$outputListdata1 = ''; 
while($row = mysql_fetch_array($sqldata))
{      
  $id = $row["id"];    
  $label = $row["label"];    
  $title = $row["title"];    
  $info = $row["info"]; 
} // close while loop 
?> 
<!DOCTYPE html> 
<html>    
<head>  
  <meta charset="UTF-8"> 
  <title>my site</title> 
</head>  
<body>     
  <div class="container">    
    <div class="content1">    
      <a href= "#" ><?php echo $title;?></a>    
    </div><!-- end of content1 -->               
    <div class="content2">          
      <?php echo $info;?>          
    </div>    
  </div><!-- end of container --> 
</body>
</html>
然后使用

$SomeLink="index.php";
echo“$nam找不到您的密码


";


它在IE、Edge和Google Chrome上使用双引号,因此与标题相同。到底是什么问题?你能用我的代码示例plz来写吗。。。因为当我像这样在$outputListdata1中插入时,它会显示错误..你能理解吗?请帮我跨过这座桥,就像你在标题上做的一样。到底是什么问题?你能用我的代码示例plz来写吗。。。因为当我像这样在$outputListdata1中插入时,它会显示错误..你能理解吗?plz帮助跨越这座桥你能用我的代码例子写它吗plz。。。因为当我像这样在$outputListdata1中插入时,它会显示错误..你能理解吗?plz帮助跨越这座桥:(是的,我试过你说的,但它在浏览器的代码视图中显示类似的东西(ctrl+u)…它只是显示变量,而不是拉动它的结果:(你能用我的代码示例plz来写它吗?…因为当我像这样插入$outputListdata1时,它显示了我的错误..你能理解吗?plz帮助跨越这座桥:(是的,我试过你说的,但它在浏览器的代码视图中显示了类似的东西(ctrl+u)…它只是显示变量,而不是拉取它的结果:(也请回答这个问题..如何写这个是对的?也请回答这个..如何写这个是对的?谢谢,我得到了一个答案,你可以帮助如何在同一个href中插入另一个变量..例如:它是对的吗?@kyan2020这取决于href中需要什么…你在上面一行写的方式只会连接两个变量ables.thank我得到了一个你能帮我在同一个href中插入另一个变量吗..例如:这是正确的方法吗?@kyan2020这取决于href中需要什么…你在上面一行写的方式只会连接两个变量。谢谢,相信我会在未来几天从像你这样有头脑的人那里学到。谢谢你回答我的问题..can您告诉我如何在a href.中插入两个变量。例如:是否正确?
连接两个字符串。
'
只标记字符串的星形/趋势,但因为您想要连接两个变量,所以不需要
'
在那里。您的将创建文本“labeltext.labeltext”谢谢,我一定会在中学习像你这样的好心肠的人即将到来。谢谢你回答我的问题。你能告诉我如何在a href中插入两个变量吗?例如:
这个
连接了两个字符串。
'
只是标记了一个字符串的星号/趋势,但是因为你想要连接两个变量,所以你不需要
'
。你的将创建文本“labeltext.labeltext”。非常感谢你的朋友花时间帮助并回答我的问题。没关系:)非常感谢