Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
AD Gallery 59
SyntaxHighlighte... 51
Newsletters v4.03 112
Facebook Like Box 128
Newsletters v4.02 58
Metro 164
Facebook Connect 171
Shoutbox Panel 128
Redactor for PHP... 106
MI Floating Side... 109
Facebook Login/R... 154
Avatar Studio v2.03 179
Relationship Sta... 98
Sexual Orientati... 116
Fisherman 143
Popular Addons
iTheme2 5804
Arise 5791
User Control v1.23 4621
Event Calendar 4051
Photowidget panel 3888
Radio-Theme red2... 3357
Highslide Gallery 3315
CSS/JavaScript D... 3231
Facebook Connect... 2986
Dynamic Menu 2894
Slideshow Lightb... 2721
L-AMANT 2659
Enigma 2636
2Dark 2606
Black 2580
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Panels and Infusions
Who is here? 1 guest(s)
 Print Thread
Coding Problem
afoster
I am trying to set up a panel with the following code:
Download source  Code
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.
afoster attached the following image:
wkwns.jpg
 
Digital Remix
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();

Inbetween your <td> tags you had random | characters, and when there is text outside tags, but inside <table> tags, example:

<table>
<tr>
<td>Hello</td> Random Text
<td>World</td>
</tr>
</table>


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
 
afoster
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?
afoster attached the following image:
regwkwnrs.jpg
 
Digital Remix
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).

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();

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
 
afoster
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.
 
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
Problem with photogallery Suspected Bugs and Errors 6 15-05-2013 17:10
Problem with picture. Installation Issues 13 14-04-2013 20:40
Problem with login v7.02.06 Installation Issues 6 11-04-2013 16:23
Shoutbox Problem Panels and Infusions 5 22-03-2013 07:34
Problem upgrading to 7.02.01 Upgrading issues 11 14-03-2013 07:15
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue