gpt4 book ai didi

php - WordPress/Wix + PHP 和 MySQL?

转载 作者:行者123 更新时间:2023-11-27 23:33:04 25 4
gpt4 key购买 nike

我成为网络开发人员已有一段时间了,在我做的所有网站中,我通常从头开始用 HTML 编写前端代码。为我提供更多定制化和可访问性,但需要花费大量时间——更不用说让它响应手机了。是否有任何网站可以处理前端,同时可以与 PHP 和 MySQL 融合在一起作为后端?

我已经尝试研究如何将 Wordpress 与 PHP 结合使用,但不知何故无法获得有关如何完全做到这一点的体面教程/信息。我遇到了 Adminer,它很好但不是很接近 PhpMyAdmin。

截至目前,我主要使用 HTML 编写前端代码。这是示例之一(不是最好的,但只是提供一个想法)

<br/>

<!-- ==== Welcome Greetings ==== -->
<h1><?php echo $txt_homeheader.' '.$user_firstname.'!';?></h1>

<br/>

<!-- ==== Post Box ==== -->
<table border = 0>
<tr>
<td style = 'padding: 0vh;' >
<center>
<?php echo $txt_writepost;?>

<br/><br/>

<form action = '' method = 'post' id = 'form_home_post'>
<textarea rows = '4' cols = '50' name = 'tb_post' form = 'form_home_post' placeholder='<?php echo $txt_postboxdesc;?>' required/></textarea>
<br/><br/>
<input type = 'submit' name = 'btn_postsubmit' value = 'Post'>
</form>
</center>
</td>
</tr>
</table>


<br/><br/>
<hr width = 40%>


<!-- ==== Post Box ==== -->
<h2><?php echo $txt_postsbanner;?></h2>
<br/>



<table border = 0 width = 40%>
<!-- ==== PHP ==== -->
<?php

//Get all posts from DB
$sql = "SELECT * FROM posts ORDER BY postdate DESC ";
$result = mysqli_query($con, $sql);

while($row = mysqli_fetch_assoc($result))
{
//Get Data from DB
$postmsg = $row['postmsg'];
$postowner = $row['postowner'];
$postdate = $row['postdate'];

$date = new DateTime($postdate);
$formatted_date = $date->format("F d, Y h:i A");

date_default_timezone_set('Asia/Manila');
$time_elapsed = timeago($postdate);

//Search and match Post owner's id to users to get name
$sql1 = "SELECT * FROM users WHERE profilecode = '$postowner' ";
$result1 = mysqli_query($con, $sql1);
$user_row = mysqli_fetch_assoc($result1);

$postowner_name = $user_row['firstname'].' '.$user_row['lastname'];

echo "<tr>";
echo "<td>";
echo "<table width = 100% style = 'border: 1px black dashed; padding: 2vh; margin: 2vh;' ><tr><td>";
echo "<ch1 style = 'font-size: 2vh;' >".$postowner_name."</ch1>";
echo "<br/>";
echo $time_elapsed.' | '.$formatted_date;
echo "<br/><br/>";
echo "<ch2 style = 'font-size: 3vh;' >".$postmsg."</ch2>";
echo "</td></td></table>";
echo "</td>";
echo "</tr>";
}


?>
<!-- ==== End PHP ==== -->
</table>

<br/><br/><br/><br/>


<!-- ==== INCLUDE FOOTER LANGUAGE TOGGLE ==== -->
<?php include('footer_language.php');?>

</center>

我想要一个像 Wix 或 Wordpress 这样的点击拖拽前端创建器,然后用 PHP 和 MySQL 修改它的后端代码。

例如:

Click an empty 'Button' on the sidebar > Drag it to your site > Right click the newly created button > Modify Code > Insert your JS/PHP code or something...

有这样的吗?非常感谢。

最佳答案

您看过 Html5 拖放吗?

function allowDrop(ev) {
ev.preventDefault();
}

function drag(ev) {
ev.dataTransfer.setData("element", ev.target.id);
}

function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("element"); // get the dragging element
var dragged_element = document.getElementById(data);
ev.target.appendChild(dragged_element);

// display the data
console.log(dragged_element);
document.getElementById('result').innerHTML = dragged_element.getAttribute('src');
}
#container-droppable {
width: 350px;
height: 70px;
padding: 10px;
border: 1px solid #aaaaaa;
}
<html>
<body>

<p>Drag the image into the rectangle:</p>

<div id="container-droppable" ondrop="drop(event)" ondragover="allowDrop(event)"></div>

<br>

<img id="drag1" src="http://via.placeholder.com/350x150" draggable="true" ondragstart="drag(event)" width="336" height="69">


<p>URL IMAGE DRAGGED:</p>
<div id="result"></div>
</body>
</html>

之后,您可以对 wordpress 后端执行 Ajax 调用。有一个钩子(Hook)可以捕获它:https://codex.wordpress.org/AJAX_in_Plugins

关于php - WordPress/Wix + PHP 和 MySQL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57385804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com