网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

Wordpress数据库连接插件

GG网络技术分享 2025-03-18 16:12 13


问题描述:

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

 $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>

  $ 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 >

</ div>

网友观点:

I guess you left there <br> from your debug echo:

//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.

标签:

提交需求或反馈

Demand feedback