Solved

how do i get the table inside?

Posted on 2009-07-11
8
177 Views
Last Modified: 2012-05-07
bare with me here because I will try and word this best I know how.

I have managed to pull the date from my vbulletin forum and show members online on the site homepage, which by the way vbulletin said cant be done???  but I did it.
Anyhow I place code outside the site but then I have issues with width, I choose 80% it looks great but when I check with another browser size its to long then I ajust and you get the picture.
size and % never seems to work, if I can just get it into my frames it would look fine.

here is a section of my code i am having trouble with.
this code at the moment has the members online outside the site frames.
I just cant seem to get it inside without screwing the design up.
remember the code is all fine, i just need to get the sql echo inside the frame so i dont need to worry about the size of that section.


</tr>
 

			</table>';

			

	

				

			

				echo '</td>

			</tr>

		</table>

		</td>

	</tr>

</table>

	

<center>

					</form>

					</td>

				</tr><tr>

					<td class="windowbg3"><center><center> </td>

				</tr

			</table>';

?><center>

<table width="62%" cellspacing="0" cellpadding="0" border="0" class="border"0">

	<tr>

					<td class="windowbg4"><center><b>Active registered members online</b> </td>

	</tr><tr>

					<td class="windowbg3"><center><center><font size="1">Active registered members online in the last 15 minutes</font></center>

					<form action="index.php?action=login&sub=1" method="post">

					<table width="100%" cellspacing="1" cellpadding="10" border="0"> 

					

							<td class="windowbg" colspan="2"><img src="ico/sub7.gif">  <font size="1" color="white">Members Online:</b></font><font size="1" color="#fff000">
 
 

                           <b>  </title></b></font></a>
 
 
 
 
 

<?php

$con = mysql_connect('localhost', '???????', '?????');

mysql_select_db('???????',$con);
 

$t = time() - 7600;

$q = mysql_query("select username FROM user WHERE lastactivity > $t");
 

while ($u = mysql_fetch_array($q))

   echo $u['username'].", ";

Open in new window

0
Comment
Question by:SonicM3
  • 5
  • 3
8 Comments
 
LVL 5

Expert Comment

by:dvz-
ID: 24832058
First of all, you're missing a closing '>' for the </tr> tag in the following snippit:

  <td class="windowbg3"><center><center> </td>
                                </tr
                        </table>';


Second of all, I'd recommend, rather than echoing HTML inside of PHP, like that big block of table that you're echoing, break out of PHP and print it as is in HTML.  Meaning, it's better to

<table>
<?php
    //some php code
    while ( $something == 'true' ) {
?>

<tr>
  <td><?php echo $someValue?></td>
 </td>

<?php
    }
?>


And third...You have have a lot of open <center> but no closing </center>.
0
 

Author Comment

by:SonicM3
ID: 24832097
i have corrected points 1 and 3 thanks.

as for point 2 i want to get it into the php because it will take care of all the size problems i have.
what would you suggest to get this code into the php?


<center>

<table width="62%" cellspacing="0" cellpadding="0" border="0" class="border"0">

	<tr>

					<td class="windowbg4"><center><b>Active registered members online</b></center> </td>

	</tr><tr>

					<td class="windowbg3"><center><font size="1">Active registered members online in the last 15 minutes</font></center>

					<form action="index.php?action=login&sub=1" method="post">

					<table width="100%" cellspacing="1" cellpadding="10" border="0"> 	

					 	<td class="windowbg" colspan="2"><img src="ico/sub7.gif">  <font size="1" color="white">Members Online:</b></font><font size="1" color="#91aadf">

                           <b>  </title></b></font></a>

<?php

$con = mysql_connect('localhost', '???', '???');

mysql_select_db('???',$con);
 

$t = time() - 7600;

$q = mysql_query("select username FROM user WHERE lastactivity > $t");
 

while ($u = mysql_fetch_array($q))

   echo $u['username'].", ";

Open in new window

0
 

Author Comment

by:SonicM3
ID: 24832102
and the code above that is as follows.
<tr>	           

                     <td class="windowbg3"><center><a href="http://mysite.com/downloads/dile2.zip"><img src="ico/update.gif" border="0"></a></center></td>

				</tr>

			</table>';

			

				echo '</td>

			</tr>

		</table>

		</td>

	</tr>

</table>

<center>

					</form>

					</td>

				</tr><tr>

					<td class="windowbg3"> </td>

				</tr>

			</table>';

?>

Open in new window

0
 
LVL 5

Expert Comment

by:dvz-
ID: 24832135
it doesn't matter if the table is printed from php or outside of php - unless you're telling to print the appropriate values, it'll continue to display incorrectly.

printing in php just makes it a headache to read and fix.

you can easily "inject" variables into the HTML code (outside of the php block)...

further, you have this:

<font size="1" color="#91aadf">
                       <b>  </title></b></font></a>
<?php

where's teh opening of the TITLE tag?  i don't think </title> should be there.



Lastly, I would recommend, if possible, to use divs rather than tables...it may make things a lil tougher to get working right in all browsers at first, but it's well worth the changeover.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:SonicM3
ID: 24832171
i see what you mean.i will check this out now, and thanks i will report back
0
 

Author Comment

by:SonicM3
ID: 24832192
na am having trouble changing this around, i was wondering if I should load the online members into another webpage and echo it in.
i got so much to sort out and i am behind way to much i was hoping to just drop the lot right in and be done and fix when in its in,
i will have a play about with it.
0
 
LVL 5

Accepted Solution

by:
dvz- earned 500 total points
ID: 24832243
you should be fine the way you have it set up...i'd probably rearrange it and do all the database work up top before printing out the body...but that's just me...

You're php code seems like it should work fine...the code in question seems to be the tables surrounding...

if the changing from tables to divs is too complicated atm, stick with your tables...though I'd still keep the tables outside of php and line them up so you can easily read them...

<table>
  <tr>
    <td></td>
   </tr>
 </table>

that way you can make sure all the necessary tags are matched with each other...

if all the tags match together, then maybe try changing the attributes of the tags such as <table> <tr> etc. to classes rather than inline attributes (i.e. width, borders, etc.)  That way you can create a CSS style sheet for browsers independently...

so <table class="tbl1">  would be able to work with each browser using a different defined style, whereas
<table width="100%" cellpadding="0" border="1"> is static for all browsers.
Some of the browsers may require special mending to get it to work.

Just a suggestion for thought

0
 

Author Comment

by:SonicM3
ID: 24832295
thanks mate yer your proberly right for that.
just trying to get the width sorted its always like 1 pixel out each side any ideas what causes this, it JUST never lines up nice with the top site
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now