Jump to content

[SOLVED] Ouput formatting...


phatgreenbuds

Recommended Posts

I think I have painted myself into a corner here. I would like to have the results of my query display in a grid format.  The code below returns my thumbnails and links them to the actual images. However the entries in the database are simply paths to these images. I thought I could do this with CSS but the way this query is returning the results I am stuck and not sure how to resolve it.  Any suggestions?

 

<?php
$query = "SELECT * FROM images";
$target = mysql_query($query); // uses the query variable defined above.
confirm_query($target); // calls to the function file.

	while ($final_target = mysql_fetch_array($target)) {
	$submitter = "{$final_target["picsubmit"]}";
	$description = "{$final_target["picdesc"]}";

	echo "<a href='{$final_target['picpath']}' target='blank'><img src='{$final_target['tnpath']}'></a>"; 

	echo "<div align=\"left\">" . $description  . "<br>" . "</div>";
	echo "<br>" . "Submitted By: " . $submitter;
	echo "<h4>" . "<hr>" . "</h4>";
	echo "<br>";
	} 	
?>

Link to comment
Share on other sites

There is a post about how to format your database output, I'm trying to find it. I'm pretty sure it's a sticky on one of the boards. Hold on, I will post it here in a few minutes hopefully once I find it.

 

EDIT

Okay...I know it is somewhere on these boards, I can't seem to find it. It's titled somthing like "DB results into rows". Does anyone else know what I'm talking about? This is a pretty common question, so I see people referencing to that post a lot.

Link to comment
Share on other sites

Here, this will give you rows of 5

 

<?php
$query = "SELECT * FROM images";
$target = mysql_query($query);
// uses the query variable defined above.
confirm_query($target);
// calls to the function file.

echo '<table>';
$counter = 1;
while ($final_target = mysql_fetch_array($target)) {
    $submitter = "{$final_target["picsubmit"]}";
    $description = "{$final_target["picdesc"]}";
    
    if ($counter == 5) {
        echo '<tr>';
        $counter = 0;
    }
    
    echo "<td><a href='{$final_target['picpath']}' target='blank'><img src='{$final_target['tnpath']}'></a>";
    
    echo "<div align=\"left\">" . $description  . "<br>" . "</div>";
    echo "<br>" . "Submitted By: " . $submitter;
    echo "<h4>" . "<hr>" . "</h4>";
    echo "</td>";
    
    $counter++;
}
echo '</table>';
?>


 

Hopefully I'm not confused on what your wanting...

Link to comment
Share on other sites

try

<?php
$query = "SELECT * FROM images";
$target = mysql_query($query); // uses the query variable defined above.
confirm_query($target); // calls to the function file.

	while ($final_target = mysql_fetch_array($target)) {
	$submitter = "{$final_target["picsubmit"]}";
	$description = "{$final_target["picdesc"]}";
	echo '<div style="float:left;padding:10px;border:2px solid;margin-left:-2px;margin-top:-2px">':
	echo "<a href='{$final_target['picpath']}' target='blank'><img src='{$final_target['tnpath']}'></a>"; 

	echo "<div align=\"left\">" . $description  . "<br>" . "</div>";
	echo "<br>" . "Submitted By: " . $submitter;
	//echo "<h4>" . "<hr>" . "</h4>";
	echo "</div>";
	} 	
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.