theme bp-corporated add a new page

i want to add a new page. The page must show the 5 first records from a new table from the database. in the admin panel, i added a new page.
1) is it neccessary to add the code to select the db ?
2) should i put the query in a function? if yes how do i have require that function?
3) any example will be appreciated.

  • aecnu
    • WP Unicorn

    Greetings Promoshake,

    i want to add a new page. The page must show the 5 first records from a new table from the database. in the admin panel, i added a new page.
    1) is it necessary to add the code to select the db ?

    From what you have described this is custom of course and yes you will need to code the page.

    2) should i put the query in a function? if yes how do i have require that function?

    This I do not have and would need to consult a qualified coder to answer your question.

    I'll see if I can get the lead developer in here to assist / give you some advice.

    Alternatively, you could see if there's a developer available at wpmu jobs who could get onto it right this minute, but we're aiming to get you sorted ourselves.

    Thanks again and it is great to have you as a WPMU Dev member, looking forward to getting this worked out!

    Cheers, Joe :slight_smile:

  • Promoshake
    • Site Builder, Child of Zeus

    thank you. i can code the php myself. My main question is should i put the code directly in the html view of the page ( in the admin panel)? or it's neccessary insert the code in a function ( i can also create the function) and edit function.php adding my function.

  • Promoshake
    • Site Builder, Child of Zeus

    ok i read the link and it was useful , but i guess i'm doing something wrong...
    in the admin panel, i add a new page with a title, in the html view i add this code

    <table border="1">
    <tbody>
    <tr>
    <th>Date</th>
    <th>Bac</th>
    <th>Nom</th>
    <th>Evènement</th>
    <th>Description</th>
    </tr>
    <?php
    $query = $wpdb->get_results( "SELECT * FROM events where evenement = 'Décès'" );
    while ($row = mysql_fetch_array($query)){$date = $row['date'];
    $bac = $row['bac'];
    $nom = $row['nom'];
    $evenement = $row['evenement'];
    $description = $row['description'];
    ?>;
    <tr>
    <th><?php echo $bac;?</th>
    <th><?php echo $nom ;?</th>
    <th><?php echo $evenement;?</th>
    <th><?php echo $description;?</th>
    </tr>
    <?php } //this ends the if?>
    </tbody>
    </table>

    when i test the page, i see my code and not the result of the select....what am i missing?

  • Promoshake
    • Site Builder, Child of Zeus

    i've create a new page custom.php from page.php
    i had @ the top

    <?php
    /*
    Template Name: Savez_vous
    */
    ?>

    but the admin page i can't see the savez_vous template for a new page. the custom.php is in the bp-corporate root folder with all the others, page.php, header.php etc...

  • Promoshake
    • Site Builder, Child of Zeus

    if a use for exemple the template-3-column.php as template (on of the template in the droplist), the page show as excepted. i tried to rename the template-3 in template-4 but the template 4 didn't show in the list. i don't know if it was you mean with your question.

  • Promoshake
    • Site Builder, Child of Zeus

    if it can help, if i make a change directly in the admin editor of one already existing page template, the modification is seen. if i make a change and upload the file via ftp no changes seen. also if i create a custom page and upload via ftp.
    my template is bp-corporate,
    i'm uploading in public_html/wp-content/themes/bp-corporate/
    am i doing something wrong?

  • Promoshake
    • Site Builder, Child of Zeus

    at the end i have modify directly in the admin the page.php in the admin page.
    I could add my code to retrieve data from the database.
    1) didn't solve my issue because i'm still unable to add a new page template.
    2) on the new page.php i want to limit the number of row of a query at 10 per page and i've generate the code in attachment.
    while the first page is shown the others seemed not to exist...
    what am i doing wrong?

  • Promoshake
    • Site Builder, Child of Zeus

    can't update the attachment...
    here is the piece of code

    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
    $start_from = ($page-1) * 20;
    $data = mysql_query("SELECT date_format(date,' %d-%m-%y') as date, bac, nom, evenement,  description FROM events where evenement = 'Décès' order by bac LIMIT $start_from, 10") or die(mysql_error());
    while($info = mysql_fetch_array( $data ))
     {
    $date = $info['date'];
    $bac = $info['bac'];
    $nom = $info['nom'];
    $evenement = $info['evenement'];
    $description = $info['description']; ?>
    
    <tr>
    <th ><?php echo $date;?></th>
    <th><?php echo $bac;?></th>
    <th><?php echo $nom ;?></th>
    <th><?php echo $evenement;?></th>
    <th><?php echo $description;?></th>
    </tr>
    <?php
     }
    ?>
    </table>
    <?php
    $sql = mysql_query("SELECT COUNT(id) FROM events") or die(mysql_error());
    $row =  mysql_fetch_row( $sql );
    $total_records = $row[0];
    $total_pages = ceil($total_records / 10);
    for ($i=1; $i<=$total_pages; $i++) {
                echo "<a href='page.php?page=".$i."'>".$i."</a> ";
    };
    ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.