Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Follow us on Facebook
Follow us on Google+
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
[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
 
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).

[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
 
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 redirects. Suspected Bugs and Errors 7 16-04-2014 20:44
DB Query problem Modifications and Requests 10 06-04-2014 18:05
Help! Coding Modifications and Requests 10 21-03-2014 18:52
Update problem 7.01.05 to 7.02.01 Suspected Bugs and Errors 8 01-03-2014 21:22
problem of infusions or panels in utf 8 lang Panels and Infusions 5 19-02-2014 03:10
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 fromVenue