Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- do.while loop to create data table


Mr_Cat - 2:42 pm on Jan 6, 2013 (gmt 0)


Hi folks,

if my database table reads like:

ID | text
17 | blah1
23 | blah2
39 | blah3

and to print it in a table I use:



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

echo "<table width='95%>";

do {
$id = $row['ID'];
$text = $row['text'];

echo "<tr>
<td>Here is the text - " . $text . "</td>
<td>The ID of the text is - " . $ID . "</td>
<td>The ID of the previous entry is - " . $x? . "</td>
</tr> ";
}

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

echo "</table>";
};



How can I find/create $x?

ie

--------------------------------
Here is the text - blah3 | The ID of the text is - 39 | The ID of the previous entry is - 23
--------------------------------

Cheers

I did wonder if just putting in another query at the top of the page might work, but figured one query is better than two :) and there must be a neat simple way.


Thread source:: http://www.webmasterworld.com/php/4533711.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com