Jump to content

[SOLVED] Help!


Trium918

Recommended Posts

The \n character is used to create a new line, correct?

Then why doesn't the code below creates a new line of

images after 5 are displayed? For instance, three rows with

five images on each.

 

<?php
  $sql = "SELECT * FROM members_images LIMIT 5";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_assoc($result)) {
	echo "<td>
	<table border=0>
	<tr>
	 <td>
	  <img src=\"./".$row['images_name']."\" width=\"100\" height=\"100\">
	 </td>
	</tr>
	</table>

	</td>\n  // here is the new line character!
	"; //End echo
      }
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />$sql<br />" . mysql_error();
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/53603-solved-help/
Share on other sites

lol A new line is something like this

 

here is a new line

 

here is also a new line.

 

In order to get it formatted in html a newline needs to be converted to < br >  but it seems like you want a new "row" not a new line. Look into the table rows.

 

If not explain what you are trying to do clearer.

Link to comment
https://forums.phpfreaks.com/topic/53603-solved-help/#findComment-264965
Share on other sites

<?php
  $sql = "SELECT * FROM members_images LIMIT 5";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result)) {
echo "<table border=\"0\">";
      while ($row = mysql_fetch_assoc($result)) {
	echo "<tr>
<td>
<img src=\"./".$row['images_name']."\" width=\"100\" height=\"100\">
</td>
</tr>"; //End echo
      }
echo "</table>";
    } else {
      echo "No results found";
    }
  } else {
    echo "Query failed<br />$sql<br />" . mysql_error();
  }
?>

 

That will output each one on its own "line"

Link to comment
https://forums.phpfreaks.com/topic/53603-solved-help/#findComment-264968
Share on other sites

lol A new line is something like this

 

here is a new line

 

here is also a new line.

 

In order to get it formatted in html a newline needs to be converted to < br >  but it seems like you want a new "row" not a new line. Look into the table rows.

 

If not explain what you are trying to do clearer.

 

lol, I donnot know what I was thinking. I am just trying to

select * the images belonging to that user and diplay all

of the images. Five to each row.

Link to comment
https://forums.phpfreaks.com/topic/53603-solved-help/#findComment-264981
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.