php - Custom database table query -


so, created custom wp database table (called "wp_my_table").

i can create new row or upload values table fine.

but new how values out of table.

below general database structure:

enter image description here

each row gets own id , has post_id associated other posts (in example, there 3 different post_id: 433, 6554, 23)

for query search, want able search rows specific post_id in descent order:

for example:

  1. look post_id of "433"
  2. get first 2 rows (order descent date): id=1, 3 selected
  3. get other info such contents

let say, there load more button load next set of data (in case, id=4, 8).

how know row next set of data , how pull out?

any suggestions appreciated. more interested in php side got js part figured out.

thanks!

i think can try use

$wpdb->get_result('sql query'); method

read this

https://codex.wordpress.org/class_reference/wpdb

your query this: it's not tested code, assumption

you need use

global $wpdb; $rows = $wpdb->get_results(      "     select id, post_id, contents, date       wp_my_table     post_id = 433      date desc     limit startrow, howmanyrows" );  foreach ($rows $row)  {     echo $row->post_id; } 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -