Jump to content

rich_greeny

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Posts posted by rich_greeny

  1. hi everyone, i'm new here and a bit of a php/mysql noob too. I'm trying to call the last posts from the forum to put on the index of my website, and the only output i've managed  to squeeze out is "Array Array Array Array". Which is a little frustrating!! Heres the code, any ideas?


    [code]<?php

    $MySQL_hostname = "localhost";
    $MySQL_username = "****";
    $MySQL_password = "****";
    $connection = @mysql_connect($MySQL_hostname,$MySQL_username,$MySQL_password) or die("Couldn't connect");
    $db_name = "****";
    $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database");
    $table_name = "phpbbmem_posts";
    $result = mysql_query("SELECT * FROM $table_name ORDER BY post_time DESC LIMIT 4");

    while ($row = mysql_fetch_array($result)) {

    $idTopic = $row["topic_id"];
    $idPoster = $row["poster_id"];

    $user=mysql_fetch_array(mysql_query("SELECT username FROM phpbbmem_users WHERE user_id='$idPoster'"));
    $thread=mysql_fetch_array(mysql_query("SELECT topic_title FROM phpbbmem_topics WHERE topic_id='$idTopic'"));



    echo "<tr style=\"width: 40%;\" height=\"0\" border=\"1\" bordercolor=\"black\">$thread</tr>\n";
    echo "<tr style=\"width: 20%;\" height=\"0\" border=\"1\" bordercolor=\"black\">$username</tr>\n";

    }

    mysql_close();

    ?>[/code]

    Thanks in advance.
  2. Hi all, i'm new to php and mysql, but starting to get the hang of it with my comp sci student housemate. I'm trying to return values inserted via a text box, but the top entry in the database won't display. If you add another to the database, then it appears, anyone have any ideas, or code to resolve the issue?

    Cheers

    Rich

    [blockquote]$sql = "SELECT * FROM $table_name ORDER BY 'date' DESC";
    $result = mysql_query($sql,$connection) or die("Couldn't execute SELECT query");
    $row = mysql_fetch_array($result);
    while ($row = mysql_fetch_array($result)){
    echo "<tr>
    <td style=\"width: 87px;\" height=\"0\"> </td>
    <td>$row[notice]
    </td>
    </tr>";
    }
    mysql_close();
    ?>[/blockquote]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.