View Thread
Post your improvements and modifications to forum index.php here.
 Print Thread
php help
afoster
I did not see a forum category that would allow me to post this so I am adding it here. First of all...this is not php-fusion related and just looking for some help. I am trying to pull information from a file and have it displayed in two columns except that I want the first piece of data in the first column, then the next one in the second column and the next one in the first column again, etc. I have looked everywhere and can't find any sample code that will allow me to do this and hope that you can help. I've got it displaying in one column already but want it in two columns. This data is being updated dynamically and the display would also be displayed dynamically.

Any help would be much appreciated.
 
Fusioneer
Can you post your php code?
How is the data in the file separated?
Warning about ParkingCrew.com! Case: ParkingCrew.com acquires NameDrive.com but earnings are not transferred despite assurances and promises. Inquiries about this are ignored! It's just a con compagny. Don't do business with them!
 
afoster
Here is the code I am using:

Download source  GeSHi: PHP
  1. <?php
  2. $team[0] = "Kansas St";
  3. $team[4] = "Kentucky";
  4. $team[8] = "Loyola, Chi";
  5. $team[12] = "Nevada";
  6. $team[16] = "Florida St";
  7. $team[20] = "Gonzaga";
  8. $team[24] = "Michigan";
  9. $team[28] = "Texas AM";
  10. $team[32] = "Villanova";
  11. $team[36] = "W. Virginia";
  12. $team[40] = "Texas Tech";
  13. $team[44] = "Purdue";
  14. $team[48] = "Kansas";
  15. $team[52] = "Clemson";
  16. $team[56] = "ASU/Syr";
  17. $team[60] = "Duke";
  18. // Change this file to match your tournament picks file
  19. $file = "playerpicks18_sw16.ttw";
  20. echo "<body bgcolor=#e3e3e3>";
  21. echo "<center>";
  22. //echo "<font size=4 color=#ff0000 face=tahoma><b>Tournament Tracker 2018 - Sweet 16 " ;
  23. //echo "";
  24. if (file_exists($file)) {
  25. $data = file_get_contents($file);
  26. $num = preg_match_all("/PLAYERID=(.*),PLAYERINFO1=(.*),PLAYERINFO2=(.*),PLAYERINFO3=(.*),PLAYERINFO4=(.*),PLAYERINFO5=(.*),G1=.*,G15=(.*),TIEBREAKER=(.*),PLAYERCOMMENT=(.*),SUBMITTED=(.*),TIMESTAMP=(.*)/i", $data, $matches);
  27. echo "<font size=2 color=#000000><b>Total Number Of Submitted Player Picks: $num</b> ";
  28. //echo $num, "";
  29. echo "<div align=center>";
  30. echo "<center>";
  31. echo "<table border=0 cellpadding=0 cellspacing=0><tr><td valign=top>";
  32. echo "<table border=1 cellpadding=2 cellspacing=1 bgcolor=#ffffff><tr>";
  33. echo "<td align=center><b>Player</b></td>";
  34. echo "<td align=center><b>Champion</b></td>";
  35. echo "<td align=center><b>Tiebreaker</b></td>";
  36. echo "<td align=center><b>Submitted&nbsp</b></td></tr>";
  37. for ($i=0; $i<$num /2; $i++) {
  38. echo "<tr>";
  39. echo "<td align=left>" . $matches[1][$i] . "</td>";
  40. echo "<td align=left>" . $team[$matches[7][$i]] . "</td>";
  41. echo "<td align=center>" . $matches[8][$i] . "</td>";
  42. echo "<td align=left>" . $matches[11][$i] . "</td>";
  43. echo "</tr>";
  44. }
  45. echo "</table>";
  46. echo "</td><td valign=top align=center width=15></td><td valign=top>";
  47. echo "<table border=1 cellpadding=2 cellspacing=1 bgcolor=#ffffff><tr>";
  48. echo "<td align=center><b>Player</b></td>";
  49. echo "<td align=center><b>Champion</b></td>";
  50. echo "<td align=center><b>Tiebreaker</b></td>";
  51. echo "<td align=center><b>Submitted&nbsp</b></td></tr>";
  52. for ($i=6; $i<$num; $i++) {
  53. echo "<tr>";
  54. echo "<td align=left>" . $matches[1][$i] . "</td>";
  55. echo "<td align=left>" . $team[$matches[7][$i]] . "</td>";
  56. echo "<td align=center>" . $matches[8][$i] . "</td>";
  57. echo "<td align=left>" . $matches[11][$i] . "</td>";
  58. }
  59. echo "</tr></table>";
  60. echo "</td></tr></table>";
  61. echo "</center>";
  62. echo "</div>";
  63. }else{
  64. echo "<h3><font size=4>There are no entries at this time : (</h3></center>";
  65. }
  66. ?>
Parsed in 0.022 seconds, using GeSHi 1.0.8.10


The file that it is pulling from is the attachethis. (It would not let me attach the file.


SECTION=HEADER
TITLE=TURBO TOURNEY PRO WEB WIZARD
VERSION=2005
POOLSIZE=16
POOLTYPE=3
TEAMSIZE=16
QUADRANT1=South
QUADRANT2=West
QUADRANT3=East
QUADRANT4=Midwest
INCLUDETIES=Y
PLAYERIDLAB=Name First, L
PLAYERINFO1LAB=Phone Number
PLAYERINFO1INC=N
PLAYERINFO1REQ=N
PLAYERINFO2LAB=Fax Number
PLAYERINFO2INC=N
PLAYERINFO2REQ=N
PLAYERINFO3LAB=E-Mail Address
PLAYERINFO3INC=Y
PLAYERINFO3REQ=Y
PLAYERINFO4LAB=Hamby
PLAYERINFO4INC=N
PLAYERINFO4REQ=N
PLAYERINFO5LAB=Hilton
PLAYERINFO5INC=N
PLAYERINFO5REQ=N
SECTION=DATA
PLAYERID=Bobby D,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@msn.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=20,G4=28,G5=32,G6=40,G7=48,G8=60,G9=4,G10=20,G11=32,G12=48,G13=4,G14=48,G15=48,TIEBREAKER=105,PLAYERCOMMENT=,SUBMITTED=3/19/2018 11:51:39,TIMESTAMP=Mon Mar 19 11:51:39 2018
PLAYERID=Shary W,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@sbcglobal.net,PLAYERINFO4=D,PLAYERINFO5=D,G1=0,G2=12,G3=16,G4=24,G5=32,G6=44,G7=52,G8=60,G9=0,G10=24,G11=44,G12=60,G13=0,G14=44,G15=44,TIEBREAKER=201,PLAYERCOMMENT=,SUBMITTED=3/19/2018 12:34:14,TIMESTAMP=Mon Mar 19 12:34:14 2018
PLAYERID=Tom O,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@gmail.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=20,G4=24,G5=32,G6=44,G7=52,G8=60,G9=12,G10=20,G11=32,G12=60,G13=20,G14=60,G15=60,TIEBREAKER=144,PLAYERCOMMENT=,SUBMITTED=3/19/2018 13:36:38,TIMESTAMP=Mon Mar 19 13:36:38 2018
PLAYERID=Marty B,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@aol.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=20,G4=24,G5=32,G6=40,G7=48,G8=60,G9=4,G10=20,G11=32,G12=48,G13=20,G14=32,G15=32,TIEBREAKER=145,PLAYERCOMMENT=,SUBMITTED=3/19/2018 15:26:1,TIMESTAMP=Mon Mar 19 15:26:01 2018
PLAYERID=Alan B,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@gmail.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=16,G4=24,G5=32,G6=40,G7=48,G8=60,G9=4,G10=24,G11=32,G12=60,G13=4,G14=60,G15=60,TIEBREAKER=137,PLAYERCOMMENT=,SUBMITTED=3/19/2018 20:15:36,TIMESTAMP=Mon Mar 19 20:15:36 2018
PLAYERID=Sara B,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1_1@yahoo.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=20,G4=24,G5=32,G6=44,G7=48,G8=60,G9=4,G10=20,G11=32,G12=60,G13=4,G14=32,G15=32,TIEBREAKER=163,PLAYERCOMMENT=,SUBMITTED=3/20/2018 0:14:51,TIMESTAMP=Tue Mar 20 00:14:51 2018
PLAYERID=Rick T,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@comcast.net,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=8,G3=20,G4=24,G5=32,G6=40,G7=48,G8=60,G9=4,G10=20,G11=32,G12=48,G13=20,G14=32,G15=20,TIEBREAKER=172,PLAYERCOMMENT=,SUBMITTED=3/20/2018 1:40:40,TIMESTAMP=Tue Mar 20 01:40:40 2018
PLAYERID=Ger-Shine,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@pacbell.net,PLAYERINFO4=D,PLAYERINFO5=D,G1=0,G2=12,G3=20,G4=24,G5=32,G6=44,G7=48,G8=60,G9=0,G10=20,G11=32,G12=48,G13=20,G14=32,G15=32,TIEBREAKER=159,PLAYERCOMMENT=,SUBMITTED=3/20/2018 9:17:21,TIMESTAMP=Tue Mar 20 09:17:21 2018
PLAYERID=Jayce D,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@gmail.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=8,G3=20,G4=28,G5=32,G6=40,G7=48,G8=60,G9=4,G10=20,G11=40,G12=60,G13=20,G14=60,G15=20,TIEBREAKER=135,PLAYERCOMMENT=,SUBMITTED=3/20/2018 10:13:30,TIMESTAMP=Tue Mar 20 10:13:30 2018
PLAYERID=Brian B,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@yahoo.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=8,G3=20,G4=24,G5=32,G6=44,G7=48,G8=60,G9=4,G10=20,G11=32,G12=60,G13=20,G14=32,G15=32,TIEBREAKER=156,PLAYERCOMMENT=,SUBMITTED=3/20/2018 14:30:26,TIMESTAMP=Tue Mar 20 14:30:26 2018
PLAYERID=Mike D,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@yahoo.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=20,G4=28,G5=32,G6=40,G7=48,G8=60,G9=4,G10=20,G11=32,G12=60,G13=4,G14=32,G15=32,TIEBREAKER=141,PLAYERCOMMENT=,SUBMITTED=3/20/2018 16:9:28,TIMESTAMP=Tue Mar 20 16:09:28 2018
PLAYERID=Chris R,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@yahoo.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=20,G4=24,G5=32,G6=44,G7=48,G8=60,G9=4,G10=24,G11=32,G12=60,G13=4,G14=60,G15=60,TIEBREAKER=134,PLAYERCOMMENT=,SUBMITTED=3/20/2018 20:17:37,TIMESTAMP=Tue Mar 20 20:17:37 2018
PLAYERID=Denise C,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@gmail.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=8,G3=20,G4=28,G5=32,G6=44,G7=48,G8=60,G9=4,G10=20,G11=32,G12=48,G13=4,G14=32,G15=32,TIEBREAKER=152,PLAYERCOMMENT=,SUBMITTED=3/20/2018 22:12:55,TIMESTAMP=Tue Mar 20 22:12:55 2018
PLAYERID=Alex M,PLAYERINFO1=,PLAYERINFO2=,PLAYERINFO3=1@aol.com,PLAYERINFO4=D,PLAYERINFO5=D,G1=4,G2=12,G3=16,G4=24,G5=32,G6=44,G7=48,G8=60,G9=4,G10=24,G11=32,G12=60,G13=24,G14=60,G15=60,TIEBREAKER=137,PLAYERCOMMENT=,SUBMITTED=3/20/2018 22:34:8,TIMESTAMP=Tue Mar 20 22:34:08 2018

Edited by Fusioneer on 22-03-2018 21:32
 
afoster
The last post is the one you need to look at...disregard the first two responses.
 
Fusioneer
Cleaned up this thread a bit and removed the email addresses from your data.

I've added your code to a panel and is displayed at the front page at the bottom.

Can you describe what you want?
Warning about ParkingCrew.com! Case: ParkingCrew.com acquires NameDrive.com but earnings are not transferred despite assurances and promises. Inquiries about this are ignored! It's just a con compagny. Don't do business with them!
 
afoster
The panel that you have added is pretty much what I want except that as you can see, it is duplicating some of the information. As an example, the information for Rick T is displayed as the last entry in column one and the first entry in column 2. This information would be dynamically updated as the players submit their information and what I want is for the first player to submit his info to appear in column one, the second player to submit his info displayed in column two, the third player to submit his info back in column one and etc. That is what I have been struggling with.
 
afoster
A friend of mine figured out how to do it dynamically. The change is in the second column code as follows:

for ($x=$i; $x<$num; $x++) { (line 85 of the file)

This line replaces the line that showed:

for ($i=22; $i<$num; $i++) { (line 100 of the file)

Thanks Fusioneer for your help.
 
afoster
Revisiting this post again. I would like to pull data from an mysql table and place it in 3 columns, very similar to the data being pulled from a txt file as noted in this thread. Here is the code I am using and it is working as except it is placing the data into 2 columns instead of three. Any assistance would be much appreciated. This is not a php-fusion related issue although some of the code you see is fusion related.



$servername = "localhost";
$username = "sfsxatjg_tjb";
$password = "T2*1OH(99.L";
$dbname = "sfsxatjg_test7";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
require_once "maincore.php";
$result = dbquery("SELECT user_name, total, paid, Won FROM ".fusion_players." WHERE Won>0 ORDER BY Won DESC");
$rows = dbrows($result);

echo "";
echo "
";
echo "Pool Tracker 2018" ;
echo "

";

   echo "Total Number Of Submitted Player Picks: $rows

";
   echo "
";
   echo "
";
   echo "
";
   echo "";
   echo "";
   echo "";
   echo "";
   echo "";
   $numrows = $rows;
   if($numrows > 0) {
   $numrows % 2  ? $numrows += 1 : $numrows;
   $rows = $numrows / 2;
$result = dbquery("SELECT user_name, total, paid, Won FROM ".fusion_players." WHERE Won>0 ORDER BY Won DESC LIMIT $rows");
while ($data = dbarray($result)) {

   $user = $data['user_name']
   $total = $data['total']
   $paid = $data['paid']
   $won = $data['Won']

      echo "";
      echo "";
      echo "";
      echo "";
      echo "";
      echo "";
}
      echo "
PlayerTotalPaidWon
" . $user . "" . $total . "" . $paid . "" . $won . "
";
      echo "
";
      echo "";
   echo "";
   echo "";
   echo "";
   echo "";

$result = dbquery("SELECT user_name, total, paid, Won FROM ".fusion_players." WHERE Won>0 ORDER BY Won DESC LIMIT $rows, $rows");
while ($data = dbarray($result)) {

   $user = $data['user_name']
   $total = $data['total']
   $paid = $data['paid']
   $won = $data['Won']

      echo "";
      echo "";
      echo "";
      echo "";
      echo "";
      echo "";
   }
}
   echo "
PlayerTotalPaidWon
" . $user . "" . $total . "" . $paid . "" . $won . "
";
   echo "
";
   echo "
";
?>
 
afoster
Never mind...I got to work.
 
Jump to Forum
New Thread Post Reply
Gebruik BBcode of HTML om naar; 'php help', te verwijzen!
BBcode:
HTML: