Jump to content

need some help here guys :confused:


archonis

Recommended Posts

There has to be a way to do this. Here is my code. Trying to pull the last nine dates then display that infomation in the row without having to write my html as echo. any help or tips?

 

// Connect to server and select databse.

mysql_connect("$host", "$dbusername", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

$date = date("Y-m-d");

 

 

// Make a MySQL Connection

$result = mysql_query("SELECT * FROM MEMBERS ORDER BY DATE DESC limit 9")

or die(mysql_error()); 

 

 

while($row = mysql_fetch_array($result))

 

{

 

$showmyphoto = "<center><a href=\"http://www.mytowndate.com/profile.php?id=" . $row['username'] . "\"><img src=\"http://www.mytowndate.com/".$row['photo'] ."\" width=\"90\" height=\"94\"><a>";

 

 

 

 

 

?>

 

<table width="70%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="30%"><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(1)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(1)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(1)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(1)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(1)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

    <td width="33%"><table width="217" border="0">

      <tr>

        <td width="211"><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(2)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(2)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(2)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(2)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(2)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

    <td width="37%"><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(3)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(3)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(3)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(3)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(3)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

  </tr>

  <tr>

    <td><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(4)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(4)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(4)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(4)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(4)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

    <td><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(5)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(5)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(5)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(5)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(5)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

    <td><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(6)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(6)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(6)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(6)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(6)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

  </tr>

  <tr>

    <td><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(7)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(7)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(7)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(7)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(7)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

    <td><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row(8)['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row(8)['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row(8)['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row(8)['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row(8)['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

    <td><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

          <tr>

            <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

              <tr>

                <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

              </tr>

            </table></td>

            <td height="21" align="left" valign="top"><div align="center"><strong><span class="style16"><?php echo $row['username'] ?></span></div></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">Age:<?php echo $row['age'] ?></td>

          </tr>

          <tr>

            <td height="21" align="left" valign="top">City:<?php echo $row['city']; ?></td>

          </tr>

          <tr>

            <td height="26" align="left" valign="top">State:<?php echo $row['state']; ?></td>

          </tr>

          <tr>

            <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row['username'] . "\">"; ?>VIEW PROFILE</td>

          </tr>

        </table></td>

      </tr>

    </table>

        <?php

}

 

 

?></td>

  </tr>

</table>

Link to comment
Share on other sites

what do you need this to look like. Because you have too many brackets. You really only need the while($row=  loop    each time through is the next row so you don't need the numbers after the arrays    $row(1)  should be just $row        You're table structure is a bit confusing I think you're making it too complicated.

 

 

 

 

 

Link to comment
Share on other sites

You need to understand that whatever is within a loop is repeated while that loop iterates. eg;

 

if ($result = mysql_query("SELECT * FROM MEMBERS ORDER BY DATE DESC limit 9")) {
  if (mysql_num_rows($result)) {   
    while ($row = mysql_fetch_array($result)) {
      echo "this content will repeat until \$result is empty<br />";
    }
  }
}

 

What that means is you only need to code the repeating html table elements once within your loop and they will be created however many times the loop iterates over.

Link to comment
Share on other sites

take a look at http://www.mytowndate.com/modrecent.php

 

I had a feeling this was going to happen.

 

 

// Connect to server and select databse.

mysql_connect("$host", "$dbusername", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

$date = date("Y-m-d");

 

$result = mysql_query("SELECT * FROM members ORDER BY online DESC limit 9")

or die(mysql_error()); 

   

 

while($row = mysql_fetch_array($result))

{

?>

<table width="70%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td width="30%"><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

            <tr>

              <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

                  <tr>

                    <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

                  </tr>

              </table></td>

              <td height="21" align="left" valign="top"><div align="center"><strong><span class="style1"><?php echo $row['username'] ?></span></div></td>

            </tr>

            <tr>

              <td height="21" align="left" valign="top">Age:<?php echo $row['age'] ?></td>

            </tr>

            <tr>

              <td height="21" align="left" valign="top">City:<?php echo $row['city']; ?></td>

            </tr>

            <tr>

              <td height="26" align="left" valign="top">State:<?php echo $row['state']; ?></td>

            </tr>

            <tr>

              <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row['username'] . "\">"; ?>VIEW PROFILE</td>

            </tr>

        </table></td>

      </tr>

    </table></td>

    <td width="33%"><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

            <tr>

              <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

                  <tr>

                    <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

                  </tr>

              </table></td>

              <td height="21" align="left" valign="top"><div align="center"><strong><span class="style1"><?php echo $row['username'] ?></span></div></td>

            </tr>

            <tr>

              <td height="21" align="left" valign="top">Age:<?php echo $row['age'] ?></td>

            </tr>

            <tr>

              <td height="21" align="left" valign="top">City:<?php echo $row['city']; ?></td>

            </tr>

            <tr>

              <td height="26" align="left" valign="top">State:<?php echo $row['state']; ?></td>

            </tr>

            <tr>

              <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row['username'] . "\">"; ?>VIEW PROFILE</td>

            </tr>

        </table></td>

      </tr>

    </table></td>

    <td width="37%"><table width="220" border="0">

      <tr>

        <td><table width="100%" border="0">

            <tr>

              <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

                  <tr>

                    <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?> </td>

                  </tr>

              </table></td>

              <td height="21" align="left" valign="top"><div align="center"><strong><span class="style1"><?php echo $row['username'] ?></span></div></td>

            </tr>

            <tr>

              <td height="21" align="left" valign="top">Age:<?php echo $row['age'] ?></td>

            </tr>

            <tr>

              <td height="21" align="left" valign="top">City:<?php echo $row['city']; ?></td>

            </tr>

            <tr>

              <td height="26" align="left" valign="top">State:<?php echo $row['state']; ?></td>

            </tr>

            <tr>

              <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row['username'] . "\">"; ?>VIEW PROFILE</td>

            </tr>

        </table></td>

      </tr>

    </table></td>

  </tr>

</table>

<?php

 

}

?>

</body>

</html>

Link to comment
Share on other sites

REALY NO!, Yes i understand that! Did you look at the link i provided? If you did you will see i have no problem putting them on top of each other. But there is rows  of three. I dont know how to do part so it looks like this.

 

111

222

333

 

and not

 

123

456

789

Link to comment
Share on other sites

how it is now is repeating the same "profile" 3 times in the same row.  as per your last comment, that is the desired result?

 

and a little off-topic.  you should really resize the profile pictures.  i clicked on one and it is over 1MB.  instead, you are just changing the size of the image within the image tag, but that doesn't take away from the images attributes.

 

think about 1,000 hits on one profile with that image being displayed 1,000 times at 1MB per visit.  1 gig worth of bandwidth gone over a picture.

Link to comment
Share on other sites

this is where i am at.

its still a no go

 

// Connect to server and select databse.

mysql_connect("$host", "$dbusername", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

$date = date("Y-m-d");

 

$result = mysql_query("SELECT * FROM members ORDER BY online DESC limit 9")

or die(mysql_error()); 

   

echo '<table width=/"70%/" border=/"0/" cellspacing=/"0/" cellpadding=/"0/"><tr><td width=/"30%/"><tr>';

 

 

 

while($row = mysql_fetch_array($result))

{

if($x == 3){

 

echo '</tr></table>';

   

echo '<table width=/"70%/" border=/"0/" cellspacing=/"0/" cellpadding=/"0/"><tr><td width=/"30%/"><tr>';

 

 

$x=0;

}

else{

$x++;

 

?>

 

<td><table width="220" border="0">

  <tr>

    <td><table width="100%" border="0">

      <tr>

        <td width="47%" rowspan="4" align="left" valign="top" bordercolor="#FF0000" bgcolor="#FFFFFF"><table width="90" height="94" border="1" bordercolor="#FF0000" bgcolor="#FFFFFF">

          <tr>

            <td height="102" bordercolor="#FF0000"><?php echo $showmyphoto; ?></td>

          </tr>

        </table></td>

        <td height="21" align="left" valign="top"><div align="center"><strong><span class="style1"><?php echo $row['username'] ?></span></div></td>

      </tr>

      <tr>

        <td height="21" align="left" valign="top">Age:<?php echo $row['age'] ?></td>

      </tr>

      <tr>

        <td height="21" align="left" valign="top">City:<?php echo $row['city']; ?></td>

      </tr>

      <tr>

        <td height="26" align="left" valign="top">State:<?php echo $row['state']; ?></td>

      </tr>

      <tr>

        <td colspan="2" align="center" valign="top"><?php echo "<a href=\"http://www.mytowndate.com/profile.php?id=" . $row['username'] . "\">"; ?>VIEW PROFILE</td>

      </tr>

    </table></td>

  </tr>

</table></td>

<?php

}

}echo '</tr></table>';

?></body>

</html>

 

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.