• Resolved da

    (@da)


    I’ve added a custom table but am having trouble returning records.

    This line has been added to the header.php:
    <?php include(‘https://127.0.0.1:8888/site-files/video-query.php&#8217;); ?>
    This file contains the query and connection string.

    The sidebar.php file contains this code:
    <p class="BoldRed">Tips go Here...<?php echo $row_GetTip['Video_Category']; ?></p>
    <p class="BoldRed"><?php echo $row_GetInstructional['Video_Category']; ?> </p>
    <?php echo $row_GetInstructional['Video_Text']; ?>

    <p>Instructions go here...<?php echo $row_GetInstructional['Video_Title']; ?></p>
    <?php echo $row_GetTip['Video_Text']; ?>
    <p><?php echo $row_GetTip['Video_Title']; ?></p>

    The hard-coded text is being displayed, but none of the records are.

    I’ve tested this on a custom template as well as the default template.

    Ideas anyone??

    david

Viewing 4 replies - 1 through 4 (of 4 total)
  • MichaelH

    (@michaelh)

    If you put your custom table in your WordPress database, then you can use the wpdb class to access and manipulate that data.

    Thread Starter da

    (@da)

    Thanks.

    Getting closer, but not quite there.

    New code = `<h2><?php _e(‘Health Tips’,’mtsjourney’); ?></h2>

      <?php $mydata = $wpdb->get_results($wpdb->prepare(“SELECT * FROM Video”));
      echo “

      "; print_r($mydata); echo "

      “; ?> //just to see everything

    `

    As you can see from the screen shot url below, the video is being returned, however, the raw array code is also being printed.

    The result can be viewed at https://daviddoonan.com/Picture%203.png

    MichaelH

    (@michaelh)

    Since $mydata is an object you need to access each ‘element’.

    For example

    if ($mydata) {
    echo $mydata[0]->Video_Category;
    echo $mydata[0]->Video_Title;
    echo $mydata[0]->Video_Featured;
    echo $mydata[0]->Video_Text;
    }

    Thread Starter da

    (@da)

    Thank you!!!!!!!!

    david

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Table’ is closed to new replies.