Web Hosting Talk







View Full Version : PHP question


dbzgod
10-19-2002, 04:10 PM
<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

Rich2k
10-19-2002, 07:43 PM
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.

dbzgod
10-19-2002, 10:10 PM
Sorry, 11 has data in it. What it needs to do is call 10 for id 11.