Get started with PHP-Fusion

Start a New Thread

Users Participated

  • afoster
    Post made: 3
  • Digital Remix
    Post made: 2

Related Threads

cBlog Panel Problem
updated 4 months ago
Autonews Problem
updated 1 year ago
Possible Wrapper Infusion Problem
updated 2 years ago
Download Module Picture Problem
updated 2 years ago

  1. PHP-Fusion Support Forums
  2. General Addon and Modification Support
  3. Panels and Infusions

Coding Problem

Help and support for problems with infusions and panels

4 Replies 1,715 Views Last Updated on 3 years ago

afoster


Veteran Member

#1

Posted 3 years ago

I am trying to set up a panel with the following code:
Code Gist: Download source  
echo "<center><table width='80%'><tr>

<td valign='top' width='50%'>";
opentable("Weekly Winners - 2012");

$sql = dbquery("SELECT * FROM fusion_regwkwnrs ORDER BY regwk_id LIMIT 0,17");
$sqlcpp = dbquery("SELECT * FROM fusion_cppwkwnrs ORDER BY cppwk_id LIMIT 0,17");
echo '<br>
<table align="center" cellspacing="1" cellpadding="1" width="100%" class="tbl-border">
<tr class="tbl2"><th bgcolor="#000066"  colspan="3"><font color="#ffffff">Regular Spreads Pool</font></th><th bgcolor="#000066" colspan="3"><font color="#ffffff">Confidence Point Pool </font></th></tr>
<tr class="tbl2"><td ><b><center>Week </b></td><td ><b><center>Name</b></td><td ><b><center>Won</b></td>|<td ><b><center>Week </b></td><td ><b><center>Name</b></td><td ><b><center>Points</b></td></tr>';
while($data = dbarray($sql))
{
while($datacpp = dbarray($sqlcpp))
{
   echo '<tr class="tbl1"><td>'.$data['regwk_id'].'</td><td>'.$data['name'].'</td>
   <td><center>'.$data['wins'].'</center></td>|<td>'.$datacpp['cppwk_id'].'</td><td>'.$datacpp['name'].'</td><td><center>'.$datacpp['points'].'</center></td></tr>';
}
}
echo '</table>';
closetable();



This is generating the panel that looks like the attached. Two questions, how do I get rid of the |||||| below Weekly Winners 2012 and why is all the data in the Regular Spreads pool repeated. The data should look similar to the Confidence Point Pool data.

I admit my coding is not very good, but I have not been able to figure out what the problem is.

Posts: 507

Joined: 11/06/2007

Digital Remix


Junior Member

#2

Posted 3 years ago

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]opentable("Weekly Winners - 2012");
echo '<table align="center" cellspacing="1" cellpadding="1" width="100%" class="tbl-border">
<tr class="tbl2">
<th bgcolor="#000066" colspan="3"><font color="#ffffff">Regular Spreads Pool</font></th>
<th bgcolor="#000066" colspan="3"><font color="#ffffff">Confidence Point Pool </font></th>
</tr><tr class="tbl2">
<td><b><center>Week </b></td>
<td><b><center>Name</b></td>
<td><b><center>Won</b></td>
<td><b><center>Week </b></td>
<td><b><center>Name</b></td>
<td><b><center>Points</b></td>
</tr>';
$sql = dbquery("SELECT * FROM fusion_regwkwnrs ORDER BY regwk_id LIMIT 0,17");
$sqlcpp = dbquery("SELECT * FROM fusion_cppwkwnrs ORDER BY cppwk_id LIMIT 0,17");
while($data = dbarray($sql)) {
while($datacpp = dbarray($sqlcpp)) {
echo '<tr class="tbl1">
<td>'.$data['regwk_id'].'</td>
<td>'.$data['name'].'</td>
<td align='center'>'.$data['wins'].'</td>
<td>'.$datacpp['cppwk_id'].'</td>
<td>'.$datacpp['name'].'</td>
<td align='center'>'.$datacpp['points'].'</td>
</tr>';
}
}
echo '</table>';
closetable();[/syntaxhighlighter]
Inbetween your <td> tags you had random | characters, and when there is text outside tags, but inside <table> tags, example:

[syntaxhighlighter brush=html,first-line=1,highlight=0,collapse=false,html-script=false]<table>
<tr>
<td>Hello</td> Random Text
<td>World</td>
</tr>
</table>[/syntaxhighlighter]

The text is displayed outside the table and it's an eyesore. The repeat of data in the first table is most likely a database side issue. Go into MyPhpAdmin and make sure your data is correct. I can't determine much based on your code with no knowledge of your database side.

The way I formatted your code is how you should always do it. Displays the code neatly in tiers, going by tables, while statements, and all. I would also separate what you have into two completely separate tables and avoid the double while statements, but that's my personal preference.

Keep at it!
~ Digital

Posts: 22

Joined: 01/10/2010

afoster


Veteran Member

#3

Posted 3 years ago

Thanks for your response, your coding is certainly much easier to follow and understand. I appreciate your help. There was an error in that you used align='right' that needs to be align="right", but otherwise it is much better formatted.

As to why the first table is not listing the correct data, I am attaching a screen shot of the table in question and as you can see it does have correct data. I have reviewed your code and mine and cannot find the reason why it just keeps listing the first row of data all the way down. Perhaps your eye can catch it.

Lastly, you stated that " I would also separate what you have into two completely separate tables and avoid the double while statements ", I am using two different tables. Perhaps I misunderstood your comment?

Posts: 507

Joined: 11/06/2007

Digital Remix


Junior Member

#4

Posted 3 years ago

This is the code with your tables separated. Putting one while loop within another wasn't the best way of getting things done. Having both displayed in one table was also very inefficient. If you really want both displayed side by side, then put both tables of data in another table, with two cells, and only one row. (Two columns, one row).

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]opentable("Weekly Winners - 2012");
echo '<table align="center" cellspacing="1" cellpadding="1" width="100%" class="tbl-border">
<tr class="tbl2">
<th bgcolor="#000066" colspan="3"><font color="#ffffff">Regular Spreads Pool</font></th>
</tr><tr class="tbl2">
<td><b><center>Week </b></td>
<td><b><center>Name</b></td>
<td><b><center>Won</b></td>
</tr>';
$sql = dbquery("SELECT * FROM fusion_regwkwnrs ORDER BY regwk_id LIMIT 0,17");
while($data = dbarray($sql)) {
echo '<tr class="tbl1">
<td>'.$data['regwk_id'].'</td>
<td>'.$data['name'].'</td>
<td align='center'>'.$data['wins'].'</td>
</tr>';
}
echo '</table>';

echo '<table align="center" cellspacing="1" cellpadding="1" width="100%" class="tbl-border">
<tr class="tbl2">
<th bgcolor="#000066" colspan="3"><font color="#ffffff">Confidence Point Pool </font></th>
</tr><tr class="tbl2">
<td><b><center>Week </b></td>
<td><b><center>Name</b></td>
<td><b><center>Points</b></td>
</tr>';
$sqlcpp = dbquery("SELECT * FROM fusion_cppwkwnrs ORDER BY cppwk_id LIMIT 0,17");
while($datacpp = dbarray($sqlcpp)) {
echo '<tr class="tbl1">
<td>'.$datacpp['cppwk_id'].'</td>
<td>'.$datacpp['name'].'</td>
<td align='center'>'.$datacpp['points'].'</td>
</tr>';
}
echo '</table>';
closetable();[/syntaxhighlighter]
This code may not work without some minor editing. I didn't test it. I also apologize for how long it took for me to answer your followup question. Have a great day!
~ Digital

Posts: 22

Joined: 01/10/2010

afoster


Veteran Member

#5

Posted 3 years ago

Thanks for your response. I ended up using a custom page to display the tables side by side. That way, it does not take up too much of the main page to list this information.

This is a learning process for me. I seem to be learning more coding and I need to spend more time learning formatting code as well. I can visualize what I want but making it happen is the hard thing. The custom page can be seen here:
http://www.fredsf...om/sports/ and click on the Weekly Winners link in the horizontal bar.

Posts: 507

Joined: 11/06/2007

Jump to Forum:
11 users are online
0 member and 11 guests