imported_salman_ahmed008
New member
i am creating a table in which the data is coming from fetching the mysql_fetch_assoc function.
i am using while loop to display all the data from the query. the problem is I want to display the data in this way;
FIELD 1 FIELD 2 FIELD 3
FIELD 4 FIELD 5 FIELD 6
i was using for loop within a for loop, but its not working. can anyone help please?
Thanks.
No there are not just six fields. Number of fields are unknown...but the number of columns are three. meaning each row will not have more then 3 columns, then it will jump to another row and continue displaying the rest.
ok I think you still didnt get it, what i am trying to say here.ok the code is here, look and ask me if u dont explain anything.
$albumid = $_GET['albumid'];
$member_id = $_SESSION['member_id'];
$image = mysql_query("SELECT * FROM picture WHERE album_id='$albumid' AND member_id='$member_id'");
while($row = mysql_fetch_assoc($image))
{
echo "<table border='1' cellspacing='20'>";
echo "<tr><td><img src='pictures/". $row['picture_location'] . "' width='400' height='240'>" . "</td>";
echo "<tr><td>". $row['picture_name']. "</td></tr>";
echo "<tr><td>". $row['picture_description']. "</td></tr>";
echo "<tr><td><input type='button' value='Delete' onclick='deletepicture();'></td></tr>";
echo "</table>";
} // while loop ends here
currently its displaying like this
picture 1
picture 2
picture 3
.
.
.
so on
What I want is;
pic1 pic2 pic3
pic4 pic5 pic6
pic7 .............so on.
i am using while loop to display all the data from the query. the problem is I want to display the data in this way;
FIELD 1 FIELD 2 FIELD 3
FIELD 4 FIELD 5 FIELD 6
i was using for loop within a for loop, but its not working. can anyone help please?
Thanks.
No there are not just six fields. Number of fields are unknown...but the number of columns are three. meaning each row will not have more then 3 columns, then it will jump to another row and continue displaying the rest.
ok I think you still didnt get it, what i am trying to say here.ok the code is here, look and ask me if u dont explain anything.
$albumid = $_GET['albumid'];
$member_id = $_SESSION['member_id'];
$image = mysql_query("SELECT * FROM picture WHERE album_id='$albumid' AND member_id='$member_id'");
while($row = mysql_fetch_assoc($image))
{
echo "<table border='1' cellspacing='20'>";
echo "<tr><td><img src='pictures/". $row['picture_location'] . "' width='400' height='240'>" . "</td>";
echo "<tr><td>". $row['picture_name']. "</td></tr>";
echo "<tr><td>". $row['picture_description']. "</td></tr>";
echo "<tr><td><input type='button' value='Delete' onclick='deletepicture();'></td></tr>";
echo "</table>";
} // while loop ends here
currently its displaying like this
picture 1
picture 2
picture 3
.
.
.
so on
What I want is;
pic1 pic2 pic3
pic4 pic5 pic6
pic7 .............so on.