Display data from database
-
Hello,
I create a site with WordPress, then I install CPT UI to create custom post types. After that, I create a table in the database with the name (wp_christian_names) and I upload that file to excel and add some data. I have more than 7000+ rows inside, see this https://ibb.co/4Fzw539.So I was thinking that how I can make 7000+ URLs for that, so I created a taxonomy-like tag system, and I add all these names only, so I will get the URL for that. now I am confused that how I can show the exact name data for that. I do a search on google and found the answer but can’t figure out how WordPress knows that this name has data in the database.
<?php global $wpdb; $table_name = $wpdb->prefix . "wp_christian_names"; $user = $wpdb->get_results( "SELECT * FROM $table_name" ); ?> <table border="1"> <tr> <th>NAME</th> <th>GENDER</th> <th>ORIGIN</th> <th>RELEGION</th> </tr> <?php foreach ($user as $row){ ?> <tr> <td><?php echo $row->name ?></td> <td><?php echo $row->gender ?></td> <td><?php echo $row->origin ?></td> <td><?php echo $row->relegion ?></td> </tr> <?php } ?> </table>
for example, I have a tag with the name Aana and want to fetch data of this name from the database.
Can anyone help me with this please.
- The topic ‘Display data from database’ is closed to new replies.