WordPress数据库连接插件
问题描述:
I made a kind of plugin just for the database connection it works but if i activate my plugin the page wil go a little bit down so actually my site will become ugly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
$servername = \"xxxx\"; // naam of ip van de machine ... 127.0.0.1 $username = \"xxxx\"; //naam van gebruiker $password = \"xxxx\"; // wachtwoord $dbname = \"xxxx\"; //db naam $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die(\"Connection failed: \" . mysqli_connect_error()); } if (isset($_GET[\"code\"]) ) { $code = $_GET[\'code\']; } else { $code = \'\'; } //$naam = \'%DR%\'; //$sql = \"SELECT * FROM docenten WHERE naam=\\\"$naam\\\"\"; $sql = \"SELECT * FROM `cadeaubon` WHERE Kortingscode like \\\"$code\\\"\"; //echo $sql; //debuggen echo \"<BR>\"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row echo \"<table>\"; while($row = mysqli_fetch_assoc($result)) { echo \"- ID: \" . $row[\"ID\"]. \" - Kortingscode: \" . $row[\"Kortingscode\"]. \" - Aantal personen: \" . $row[\"AantPersonen\"] . \" - Naam: \" . $row[\"Naam\"] . \" - Achternaam: \" . $row[\"Achternaam\"] . \" - Leeftijd: \" . $row[\"Leeftijd\"] . \" - Datum: \" . $row[\"Datum\"].\"<br>\"; } echo \"</table>\"; } else { echo \"\"; } mysqli_close($conn); |
this is my code and i thought maybe it will help if the result will display at the bottom of the page but i dont know how
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议
我为它所使用的数据库连接创建了一种插件但是如果我激活了我的插件,那么页面将会是 实际上我的网站会变得难看</ p>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
$ servername =“xxxx”; // na van of ip van ... 127.0.0.1 $ username =“xxxx”; // naam van gebruiker $ password =“xxxx”; // wachtwoord $ dbname =“xxxx”; // db naam $ conn = mysqli_connect($ servername,$ username,$ password,$ dbname); if(!$ conn){ die(“Connection failed:”。mysqli_connect_error()); } if(isset($ _ GET [“code”])) { $ code = $ _GET [\'code\']; } else { $ code =\'\'; \\ n} // $ naam =\'%DR%\'; // $ sql =“SELECT * FROM docenten WHERE naam = \\”$ naam \\“”; $ sql =“SELECT * FROM` cadeaubon` WHERE Kortingscode喜欢\\“$ code \\”“; // echo $ sql; // debuggen echo“&lt; BR&gt;”; $ result = mysqli_query($ conn,$ sql); if if(mysqli_num_rows($ result)&gt; 0){ //输出 每行的数据 echo“&lt; table&gt;”; while($ row = mysqli_fetch_assoc($ result)){ echo“ - ID:”。 $行[ “ID”]。 “ - Kortingscode:”。 $行[ “Kortingscode”。 “ - Aantal personen:”。 $ row [“AantPersonen”]。 “ - 纳姆:”。 $ row [“Naam”]。 “ - Achternaam:”。 $ row [“Achternaam”]。 “ - Leeftijd:”。 $ row [“Leeftijd”]。 “ - 基准:”。 $ row [“Datum”]。“&lt; br&gt;”; } echo“&lt; / table&gt;”; } else { echo“”; } mysqli_close($ conn); </ code> </ pre> <p>这是我的代码,我想也许如果结果会显示在页面底部但我不知道如何</ p > </ div> <h5>网友观点:</h5> <div> <p>I guess you left there <code><br></code> from your debug echo:</p> <pre><code>//echo $sql; //debuggen echo \\\"<BR>\\\"; |
However I don\'t know where in code this gets executed and how it integrates with WordPress. If the following table is shown inside content area of the page, the <br>
shouldn\'t affect your site design other than pushing the table one line down.
It also seems to be a bit of overkill to create your own database connection - I would think WordPress already is connected and it would be preferable to use its own connection, unless it is a completely different database.
1. 带 [亲测] 说明源码已经被站长亲测过!
2. 下载后的源码请在24小时内删除,仅供学习用途!
3. 分享目的仅供大家学习和交流,请不要用于商业用途!
4. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
5. 本站所有资源来源于站长上传和网络,如有侵权请邮件联系站长!
6. 没带 [亲测] 代表站长时间紧促,站长会保持每天更新 [亲测] 源码 !
7. 盗版ripro用户购买ripro美化无担保,若设置不成功/不生效我们不支持退款!
8. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
9. 如果你也有好源码或者教程,可以到审核区发布,分享有金币奖励和额外收入!
10.如果您购买了某个产品,而我们还没来得及更新,请联系站长或留言催更,谢谢理解 !
GG资源网 » WordPress数据库连接插件