ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

exp:weblog:entries passin data to create a variable

September 24, 2010 2:32pm

Subscribe [1]
  • #1 / Sep 24, 2010 2:32pm

    webster10

    9 posts

    I need to do a special query on one of my web pages.  I need to know how to turn a return from exp:weblog:entries into a variable to be used in a php query.  I specifically need the entry_id number

    Something like this:

    {exp:weblog:entries weblog="friends"}
    {name}

    (Grab The Entry_Id of the printed name and make it into Entry_Id of name = $name)
    {/exp:weblog:entries}

    <?php
    // CONNECT TO DATABASE  //
    include('/home/connect.php');
    $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' .mysqli_connect_error());
    
    $q = "SELECT entry_id FROM exp_weblog_data WHERE field_id_10='$name'";
    $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n
    MySQL Error: " . mysqli_error($dbc));
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases