Fork me on GitHub

How to read out MySQL Data??  Bottom

  • Hi together,

    i want to programm a new module for my page... The init and the delete are working. I also have DB-table with data in it. The working command in PHP is (with escape-chars):

    pnuserapi.php:

    Code

    //part of code in function "gettitles"
    list($dbconn) = pnDBGetConn();
    $sql = "SELECT pn_letter AS \"letter\", pn_genre AS \"genre\", pn_titel AS \"title\", pn_gid AS \"gid\" FROM zk__cheats_spiele";
    //....More Code here...
    $sql.= " ORDER BY pn_titel ASC; ";
    $result = $dbconn->Execute($sql);


    Then i gave the value of $result into a new variable $titles in pnuser.php:

    Code

    $titles = pnModAPIFunc('Cheats', 'user', 'gettitles', array('genre' => 'Racing', 'letter' => 'W'));
    $pnRender->assign('titles', $titles);
    return $pnRender->fetch('cheats_user_main.html');


    This variable $titles i assigned in pnRender. Now i don't know how to read out in the template:




    ^^Isn't this the right way? What i must do? The Function doesn't show anything, altough there are data in the DB.

    Sry fr my bad - worse icon_wink english and thanks in advance...



    edited by: WorldRacer, Jul 18, 2008 - 10:50 AM
  • Assuming that your top code goes on to read each returned result into an array that you then return and assign to pnRender, then what you're looking for is probably something like...

    Code

    <!--[foreach from=titles item=title]-->
        Letter: <!--[$title.letter]-->
        Genre: <!--[title.genre]-->
    <!--[/foreach]-->


    * EDIT - Forgot to close the code tag. Oops.

    Without seeing all the code, this is just a guess. But, a good start might be to read the Smarty documentation (hopefully available in your first language):

    http://www.smarty.net/docs.php



    edited by: dreamingmonkey, Jul 19, 2008 - 12:54 PM

    --
    Help Now! Fast and affordable help for do-it-yourself webmasters from Wicked Viral :: Chicago's Only Web Development Firm Specializing in Social Networking Integration
  • You should also note that for Zikula we provide a database abstraction layer called DBUtil which takes care of the low-level SQL stuff for you. It makes it much easier to write database code and generates portable SQL ...

    Greetings
    R

This list is based on users active over the last 60 minutes.