General Community > Scripting Help

Pulling out information from a database table

(1/1)

Liam_michael:
I have this code that I created, but it only displays one of the entries in the table. I want it to display all the entries in table. What must I do so that the limit of how many are shown is limitless?


--- Code: ---$dbresult = db_query("
SELECT
custom, id, user_id
FROM smf_treas_donations
                ORDER BY RAND()
", __FILE__, __LINE__);
list ($custom, $id, $user_id) = mysql_fetch_row($dbresult);
        mysql_free_result($dbresult);

echo '<ul style="margin-top: 1ex;" id="member_blocks_wrapper">';

echo '<li style="width: 25%; font-weight: bold;" class="member_containers"><a href="http://biology-forums.com/index.php?action=profile;u=',$user_id,'" />',$custom,'</a></li>';

echo'</ul>';
--- End code ---

Arantor:

--- Code: ---echo '<ul style="margin-top: 1ex;" id="member_blocks_wrapper">';

$dbresult = db_query("
SELECT
custom, id, user_id
FROM smf_treas_donations
                ORDER BY RAND()
", __FILE__, __LINE__);

while ($row = mysql_fetch_row($dbresult))
{
list ($custom, $id, $user_id) = $row;
echo '<li style="width: 25%; font-weight: bold;" class="member_containers"><a href="http://biology-forums.com/index.php?action=profile;u=',$user_id,'" />',$custom,'</a></li>';
}

echo'</ul>';

mysql_free_result($dbresult);
--- End code ---

Liam_michael:
Worked, marking as solved. Thank you, Arantor.

Navigation

[0] Message Index

Go to full version