Results 1 to 3 of 3

Thread: PHP question

  1. #1
    Join Date
    Jul 2001
    Posts
    424

    PHP question

    <p>
    <?php
    //Now we get into grabbing chat logs...
    $query = mysql_db_query ($dbname,"SELECT `id`,`input`,`response` FROM `conversationlog` WHERE 1 AND `input` LIKE 'no' order by id",$db) or die (mysql_error());
    ?>
    <table align="center" width=100% border=0 cellspacing=3 cellpadding=0>
    <tr>
    <td>ID</td>
    <td>Input</td>
    <td>Response</td>
    </tr>
    <?php

    while ($rows = mysql_fetch_array($query)) {
    echo "
    <tr>
    <td>$rows[id]</td>
    <td>$rows[input]</td>
    <td>$rows[response]</td>
    </tr>";
    $rows[id] = "$id";
    $query2 = mysql_db_query ($dbname,"SELECT `$id-1`,`input`,`response` FROM `conversationlog` WHERE 1 AND `input` LIKE 'no' order by id",$db) or die (mysql_error());
    while ($rows = mysql_fetch_array($query2)) {
    echo "
    <tr>
    <td>$rows[id]</td>
    <td>$rows[input]</td>
    <td>$rows[response]</td>
    </tr>";
    }
    }
    ?>
    </table>
    </p>

    </body>

    </html>

    That is the mani code of what I am using to grab information from a mysql database. The script works fine, its just im stuck on how to do this part.

    I want to add a fourth and fixth <td> to those that will echo back the input and response for the id before the one its calling now.

    Exmaple:

    It calls the id 11 with the input, no, response, no what. Then for the fourth and fixth columns I want it to echo back the id 10 (the one before) with the response and input.

    Basically, it calls the id 11 data and then subtracts one and calls that data.

    Could this be done, and how?

    Thanks,

    Neo
    Last edited by dbzgod; 10-20-2002 at 09:47 PM.

  2. #2
    Join Date
    May 2002
    Location
    UK
    Posts
    2,997
    I don't get what you are asking.

    Basically, it calls the id 11 data and then subtracts one and calls that data.
    Are you saying you only call 10 if 11 is empty or always call 10 for id 11?

    If you are wanting to display the first three columns with 11 and the next two with 10, personally I would put it all in an array first so it makes it easier to mix and match id numbers later.

  3. #3
    Join Date
    Jul 2001
    Posts
    424
    Sorry, 11 has data in it. What it needs to do is call 10 for id 11.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •