0

Good evening I have this code in PHP that serves to list the latest topics in a forum (IPBOARD):

<?php


    // CONFIGURAÇÕES DE CONEXÃO
    $connect = mysql_connect("localhost","root","senha") or die (mysql_error());

    $select = mysql_select_db("forum") or die(mysql_error());

    // URL DO FÓRUM
    $url = "http://endereço do forum/";

    // LIMITE DE LINKS QUE IRÃO APARECER
    $limit = 5;

    // ID DO FóRUM QUE DESEJA LISTAR OS TÓPICOS
    $forumid = 2;

    // SELECIONANDO TÓPICOS E ORDENANDO PELA DATA
    $sql = "SELECT * FROM `topics` WHERE `forum_id` = '$forumid' ORDER BY `start_date` DESC LIMIT $limit";

    // EXECUTANDO A QUERY
    $query = mysql_query($sql) or die (mysql_error());

    // EFETUANDO LOOP PARA LISTAR OS TÓPICOS
    while($row = mysql_fetch_array($query)){

        // DATA DE POSTAGEM
        $data = date( 'd/m', $row['start_date']);

        // ID DO TÍTULO EXIBIDO NO LINK
        $tid = $row['tid'];

        // TÍTULO DO TÓPICO
        $title = $row['title'];

        // TÍTULO EXIBIDO NO LINK
        $titleid = $row['title_seo'];

        // CONSTRUINDO TABELA PARA ORDENAR A EXIBIçÃO

        echo "<table border='0'>";
        echo "<td><span style='margin-left: 10px; font:bold 12px arial, verdana, tahoma; letter-sp acing:-1.1px; color:#AD00FF;'>".substr( $data , 0 , 5 )."</span></td>";

// EXIBINDO TÍTULO DO TÓPICO COM LINK
        echo "<td><a href='".$url."index.php?/topic/".$tid."-".$titleseo."' target='_self' class=' link-news'>".$title."</a></td>";

        //FECHANDO TABELA
        echo "</table>";
    }


?>

I made this other code based on the above, it pulls the information from the database, but I am not knowing how to make it list the topics as in the code above. I think I have to convert it to PHP to list.

<link rel="stylesheet" type="text/css" href="./content.css">    

<div class="boxBody">

<div id="homeNews">

    <span class="ntype t-new"></span>
    <img src="icon.fw.png" alt="">    <span class="title"> <?php echo "<td><a href='".$url."index.php?/topic/".$tid."-".$titleseo."' target='_self' class='link-news'>".$title."</a></td>"; ?></span>
    <span class="date"><?php echo "<td><span>".substr( $data , 0 , 5 )."</span></td>"; ?></span>


</div>
<a href="http://" class="iconLink" style="opacity: 0.8;">Ver noticias anteriores</a> 
</div>

Please help me! I know that those who understand that PHP is easy.

4
Contributors
3
Replies
13
Views
3 Years
Discussion Span
Last Post by diafol
0

Can we see the code you've made, errors you're getting?

Maybe because all of your code has spanish comments/link, or it's just me, but I don't really understand what youre trying to achive here. Please detail what your application is, and exactly what you need help with (i.e. displaying data from a database)

Help us to help you, and I hope we can sort you out,

Matt

0

And I am still not sure what your question is??? You gave us a valid PHP in the first code section, but I have no clue what you are trying to do in the second section?

In the first PHP section, what it does is to 1)connect to the database and 2)iterate through each records to populate the table data in HTML. In the second PHP section, I do not see any part of yours that connect to a database??? So you cannot simply create a table without retrieving data from the server first.

Edited by Taywin

0

The second piece of code is a mess and you do not provide the whole code for it. If you want to programme, learn the basics first. There are many good tutorials out there. Mixing html and php is horrible, but unavoidable, but we try to minimise this as far as possible.

In addition, please read this: http://bit.ly/Dwebphp

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.