Jump to content


Photo

PHP Echo


  • Please log in to reply
7 replies to this topic

#1 ItsWesYo

ItsWesYo
  • Members
  • PipPipPip
  • Advanced Member
  • 110 posts

Posted 05 July 2006 - 04:20 AM

http://www.evermoref...items/index.php

I would like 3 items per row/line.

I saw somewhere you can do that using php echoes.

But I don't know how to do that.

Your help is greatly appreciated.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 05 July 2006 - 04:23 AM

See here.

#3 ItsWesYo

ItsWesYo
  • Members
  • PipPipPip
  • Advanced Member
  • 110 posts

Posted 05 July 2006 - 04:40 AM

Hmm. Well, here is what my code is:


<?
mysql_connect("localhost","usernameHIDDEN","passwordHIDDEN"); 
mysql_select_db("tableHIDDEN"); 
$result = mysql_query("SELECT * FROM items ORDER BY name");
while($r=mysql_fetch_array($result))
{	
   $name=$r["name"];

echo "

$name<br>

";
}
?>


#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 05 July 2006 - 04:42 AM

And? See here.

#5 ItsWesYo

ItsWesYo
  • Members
  • PipPipPip
  • Advanced Member
  • 110 posts

Posted 05 July 2006 - 04:48 AM

I'm not talking about that kind >_>

I saw one last time that was like:

echo " <tr> ";
echo "<td>";

Something like that.

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 05 July 2006 - 04:53 AM

The example Im pointing out is how it is done.

#7 mrwhale

mrwhale
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 05 July 2006 - 08:54 AM

This should work.

<?php

mysql_connect( "localhost", "usernameHIDDEN", "passwordHIDDEN" ); 
mysql_select_db( "tableHIDDEN" );

$query = mysql_query( "SELECT * FROM items ORDER BY name" );

echo "<table>";

while( $row = mysql_fetch_array( $query ) )
{
      $x++;

      if( $x == 1 ) echo "<tr>";

      echo "<td>" . $row['name'] . "</td>";

      if( $x == 3 )
      {
            echo "</tr>";
            $x = 0;
      }
}

echo "<table>";

?>


#8 ItsWesYo

ItsWesYo
  • Members
  • PipPipPip
  • Advanced Member
  • 110 posts

Posted 05 July 2006 - 10:29 AM

Thanks to both of you.

It worked.

Thorpe -- It wasn't I didn't understand it, I just needed to incorporate it into mine =\




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users