Please help with getting data from a table outside of wordpress while in a post
-
Hello everyone, I wanted to originally reply to this post and see if anyone could help me do something similar, but it was closed:
To begin, I don’t know if what I’m asking for is even possible as I am ambitious, but really don’t have much skill with PHP, just an idea I can’t get out of my head until it’s done.
I put a bunch of data into a MySQL db where I have WP also installed. I named all of the tables with the same prefixes as WP (ex: “wp_yyz_users” is what WP looks like, my tables look like “wp_yyz_dlp_rpg_characters”)
My eventual goal is to make a character sheet for an RPG that users can input their character information into WP and that data can be used inside WP to play the game. We got it working in Excel, but now I’m trying to get the data all in one place we can access easily and play from using the same data.
The location of the HTML I made the character sheet in as an example is at https://dangerouslylow.com/rpg
I would like to take the data from the tables and fill that in.
Below is the code of the HTML of the tables.
<!–Above is the top row of fields–>
<tr style=”height: 15.0pt;”>
<td class=”xl65″ style=”height: 15.0pt;” bgcolor=”#000000″ height=”20″></td>
<!–Change this out for an image file at some point–>
<td class=”xl136″ style=”text-align: center;” colspan=”5″ rowspan=”15″>[picture of animal]</td>
<td class=”xl108″ colspan=”2″ bgcolor=”#000000″><span style=”color: #ffffff;”>Name:</span></td>
<!–Input box needed for the name of the character–>
<td class=”xl116″ colspan=”10″></td>
<td class=”xl65″ bgcolor=”#000000″></td>
</tr>The first step is the biggest hurdle and I can’t for the life of me figure out where in the post to put the PHP that will access the correct table and not reformat everything.
global $wpdb;
$results = $wpdb->get_results( ‘SELECT * FROM wp_options WHERE option_id = 1’, OBJECT );My best guess is that it will look something like that.
For me, the table I want to access is “wp_yyz_dlp_rpg_characters” and the field I want to return information from is “character_name” so that I can put it in the place indicated.
I think if I can get some help filling in the data for one field, I can at least make the rest of the sheet work by doing the same for each field.
Please help if you can.
- The topic ‘Please help with getting data from a table outside of wordpress while in a post’ is closed to new replies.