Solved

how do i get the table inside?

Posted on 2009-07-11
8
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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
 

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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