如何从数据库获取数据到wordpress?

时间:2017-08-25 03:52:01

标签: php mysql wordpress

我创建了一个教育网站,其中学生注册了唯一的ID,直到现在没有问题,但我想从我的数据库中显示一些具有特定唯一ID的信息。我已经在wordpress中创建了网站。请帮助我

2 个答案:

答案 0 :(得分:0)

// 1st Method - Declaring $wpdb as global and using it to execute an SQL 
   query statement that returns a PHP object

   global $wpdb;
   $results = $wpdb->get_results( 'SELECT * FROM wp_options WHERE option_id = 1', OBJECT );

  // 2nd Method - Utilizing the $GLOBALS superglobal. Does not require 
   global keyword ( but may not be best practice )

  $results = $GLOBALS['wpdb']->get_results( 'SELECT * FROM wp_options WHERE option_id = 1', OBJECT );

答案 1 :(得分:0)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
     <input type="text" name="name" value="Tom">
     <input type="text" name="location" value="China">
     <input type="text" name="id" value="993">
     <input type="text" name="accountId" value="123">
     <input type="text" name="id" value="222">
     <input type="text" name="accountId" value="333">
</form>

<form>
     <input type="text" name="name" value="Test">
     <input type="text" name="location" value="Test112">
     <input type="text" name="id" value="22">
     <input type="text" name="accountId" value="78">
     <input type="text" name="id" value="00">
     <input type="text" name="accountId" value="44">
</form>
<button>
Submit
</button>