It outputs blank for some reason, here is my current code.

<table>
<?php
$puserid = $anothervalue;
echo public_Images($puserid);
?>
</table>
function  public_Images($puserid){
		
	$sql = "SELECT * FROM `ue-userfile` WHERE userid = '$puserid' AND albumname ='Public' ORDER BY date DESC";
$result = mysql_query($sql);
$count = 0;

while($row = mysql_fetch_array($result)){
if ($count % 4 == 0)
echo'<tr>';
echo'<td><img src="u/'.$puserid.'/thumbs/'.$row['name'].'" class="images"/></td>';
if ($count % 4 == 3)
echo '</tr>';
$count++;
}

return;
}

anything you see or know i dont ? hehe

Dani AI

Generated

A common cause for a blank table here is a mismatch between how the function outputs HTML and how it is called. The thread author later marked the problem resolved; typical fixes are either (A) have the function return the HTML string and then echo that return, or (B) let the function echo directly and call it without echo. Also check the SQL result and file paths if nothing is returned.

Example (modern, safe pattern): have the routine return a string and use prepared statements and escaping. The snippet below uses mysqli and shows closing a partially filled final row and basic HTML escaping.

function buildImageRows($mysqli, $userId, $perRow = 4) {
    $sql = "SELECT filename FROM user_files WHERE userid = ? AND albumname = 'Public' ORDER BY date DESC";
    $stmt = $mysqli->prepare($sql);
    if (!$stmt) return '';
    $stmt->bind_param('s', $userId);
    $stmt->execute();
    $stmt->bind_result($name);

    $out = '';
    $i = 0;
    while ($stmt->fetch()) {
        if ($i % $perRow === 0) $out .= '<tr>';
        $safe = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
        $out .= '<td><img src="/uploads/' . rawurlencode($userId) . '/thumbs/' . $safe . '" alt=""></td>';
        $i++;
        if ($i % $perRow === 0) $out .= '</tr>';
    }
    if ($i % $perRow !== 0) $out .= '</tr>';
    $stmt->close();
    return $out;
}

echo '<table>';
echo buildImageRows($mysqli, $userId);
echo '</table>';

Quick troubleshooting tips: enable error reporting and check the query error message, verify the thumbnail paths and file permissions, and escape filenames to avoid XSS. Migrate away from old mysql_* calls; use mysqli or PDO and prepared statements to prevent SQL injection. See the PHP prepared-statement guide (mysqli quickstart prepared statements) and the escaping functions (htmlspecialchars, rawurlencode). For SQL injection background see OWASP (SQL Injection).

Solved it, thanks for the help!! :D


...:P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.