Categories > TinyButStrong general >

Load template - Form - POST Problem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Kevin Minnelli
Date: 2008-05-05
Time: 05:12

Load template - Form - POST Problem

Okay I know I should post my code but let me explain my problem first and maybe someone can just point me n the right direction.

I have the prob.php load my htm -  $TBS->LoadTemplate('probTBS.htm') ;
Now I know I should call my sql prior to this and do the MergeBlock after this statement BUT I have a form I need to submit first and inside my form is where I call sql and do the MergeBlock
$ps1="SELECT * FROM Prob blah blah blah";
$TBS->MergeBlock('blk1',$cnxid, $ps1) ;

So as you can imagine my page loads with all my [blk1.Foo] data everywhere but one I look past it and hit submit on my form all is wonderful in TBS land.

So question, how in the world can I hide all my blk info and keep it empty until someone submits my form? I tried the [blk1;block=tr;nodata] but this didn't work because I think the MergeBlock isn't submitted yet.

Anyhow, I want my page to load my template, all of my blk info empty until a user hits submit on my form then the blk1 data will be populate. When they submit the second time the blk2 data will show. I have this all working blk1 thru blk7 but its just the inital page that is killing me.

Any help or push in the right direction would be great.

Kevin Minnelli

Okay I'll post the cod- but this is a sample of my full page, I didn't want to post too much data.

PHP - prob.php
<?php
include_once('tbs_class_php5.php') ;
include ('cnxmysql.php');
$TBS = new clsTinyButStrong ;
$TBS->NoErr = true;
if(isset($_GET['id'])) { $id= $_GET['id']; } else { $id=100; }
if(isset($_GET['ps'])) { $ps= $_GET['ps']; } else { $ps=1; }
$sliderEng=66; //For testing just hardcode it


$TBS->LoadTemplate('probTBS.htm') ;

///////////////////////////////////////////////////////////////////
$ComponentsForm = $_POST['ComponentsForm'];
if ($ComponentsForm == "True")
{
$details = "from ComponentsForm";

$RandomTime=RAND(1,100);
   
$sql_upd1="INSERT INTO Prob(DriverID, PSession , PEng ,PTime)
VALUES ('$id', '$ps', '$sliderEng', '$RandomTime')";

mysql_query($sql_upd1);   

$ps1="SELECT * FROM Prob WHERE DriverID='$id' and PSession=1";
$ps2="SELECT * FROM Prob WHERE DriverID='$id' and PSession=2";
$ps3="SELECT * FROM Prob WHERE DriverID='$id' and PSession=3";
$TBS->MergeBlock('blk1',$cnxid, $ps1) ;
$TBS->MergeBlock('blk2',$cnxid, $ps2) ;
$TBS->MergeBlock('blk3',$cnxid, $ps3) ;

$ps=$ps+1;   

$sqlTime="SELECT Prob.DriverID, Min(Prob.PTime) AS BestPTime
FROM Prob
GROUP BY Prob.DriverID
ORDER BY Min(Prob.PTime)";
$TBS->MergeBlock('blkTimes',$cnxid, $sqlTime) ;   

};
mysql_close($cnx_id) ;
$TBS->Show() ;

?>

HTML - probTBS.htm
<html>
<body>
    <div id="main">
<form action="prob.php?id=[var.id]&ps=[var.ps]" method="post" name="ComponentsForm">
  <h1>Prob</h1>
              <table class="small" style="border-top: 3px double #888888;" width="100%"  border="0" cellspacing="0" cellpadding="2"><tr valign="top" bgcolor="e4ebf1"><td height="126" bgcolor="#FFFFCC"><table class="small" style="border-top: 3px double #888888;" width="100%"  border="0" cellspacing="0" cellpadding="2">
                <tr bgcolor="#8aa7c2">
                  <td colspan="11" bgcolor="#000000" style="color:#000000;font-weight:bold;font-size:9px;">&nbsp;</td>
                </tr>
                <tr style="color:#FFFFFF;font-weight:bold;" bgcolor="#4a6f8e">
                  <td width="16%" bgcolor="#0066FF"><div align="center"></div></td>
                  <td width="4%" bgcolor="#0066FF">&nbsp;</td>
                  <td width="8%" bgcolor="#0066FF"><div align="center">Set</div></td>
                  <td width="7%" bgcolor="#0066FF"><div align="center">P1</div></td>
                  <td width="7%" bgcolor="#0066FF"><div align="center">P2</div></td>
                  <td width="7%" bgcolor="#0066FF"><div align="center">P3</div></td>
                  <td width="51%" bgcolor="#0066FF">&nbsp;</td>
                </tr>
                <tr valign="top" bgcolor="e4ebf1">
                  <td bgcolor="#99FFFF">Eng Value</td>
                  <td bgcolor="#99FFFF">&nbsp;</td>
                  <td width="8%" bgcolor="#99FFFF"><div align="center">
                    <input name="sliderEng" id="sliderEng" type="Text" size="3" value=50>
                  </div></td>
                  <td bgcolor="#99FFFF"><div align="center">
                    [blk1.PEng]<br />
                    </div></td>
                  <td bgcolor="#99FFFF"><div align="center"> [blk2.PEng </div></td>
                  <td bgcolor="#99FFFF"><div align="center"> [blk3.PEng] </div></td>
                  <td bgcolor="#99FFFF">&nbsp;</td>
                </tr>
                <tr valign="top" bgcolor="e4ebf1">
                  <td bgcolor="#99FF33">Time Random</td>
                  <td bgcolor="#99FF33">&nbsp;</td>
                  <td width="8%" bgcolor="#99FF33"><div align="center">
                    <input type="submit" class="style15" value="Submit" />
                    </input>
                  </div></td>
                  <td bgcolor="#99FF33"><div align="center"> [blk1.PTime] </div></td>
                  <td bgcolor="#99FF33"><div align="center"> [blk2.PTime] </div></td>
                  <td bgcolor="#99FF33"><div align="center"> [blk3.PTime] </div></td>
                  <td bgcolor="#99FF33">&nbsp;</td>
                </tr>
              </table></td>
                  </tr>
              </table>
              <p>&nbsp;</p>
              <table class="small" style="border-top: 3px double #888888;" width="100%"  border="0" cellspacing="0" cellpadding="2">
                <tr bgcolor="#8aa7c2">
                  <td colspan="9" bgcolor="#000000" style="color:#000000;font-weight:bold;font-size:9px;">&nbsp;</td>
                </tr>
                <tr style="color:#FFFFFF;font-weight:bold;" bgcolor="#4a6f8e">
                  <td width="14%" bgcolor="#0066FF">ID</td>
                  <td width="5%" bgcolor="#0066FF">&nbsp;</td>
                  <td width="10%" bgcolor="#0066FF">Random Time</td>
                  <td width="63%" align="center" bgcolor="#0066FF">&nbsp;</td>
                  <td width="8%" align="center" bgcolor="#0066FF">&nbsp;</td>
                </tr>
                <tr valign="top" bgcolor="e4ebf1">
                  <td bgcolor="#CCCCCC">[blkTimes.DriverID;block=tr]</td>
                  <td bgcolor="#CCCCCC">&nbsp;</td>
                  <td bgcolor="#CCCCCC"><div align="center">[blkTimes.BestPTime]</div></td>
                  <td align="middle" bgcolor="#CCCCCC"><div align="center"></div></td>
                  <td align="middle" bgcolor="#CCCCCC"><div align="center"></div></td>
                </tr>
              </table>
    <p>&nbsp;</p>
              <p>&nbsp;</p>
                <p>&nbsp;</p>
          </form>

</div>
</body>
</html>
By: Skrol29
Date: 2008-05-05
Time: 14:54

Re: Load template - Form - POST Problem

Is this what you're looking for?

$submit = isset($_GET['id']);

if ($submit) {
  $ps1="SELECT * FROM Prob WHERE DriverID='$id' and PSession=1";
  $ps2="SELECT * FROM Prob WHERE DriverID='$id' and PSession=2";
  $ps3="SELECT * FROM Prob WHERE DriverID='$id' and PSession=3";
  $TBS->MergeBlock('blk1',$cnxid, $ps1) ;
  $TBS->MergeBlock('blk2',$cnxid, $ps2) ;
  $TBS->MergeBlock('blk3',$cnxid, $ps3) ;
} else {
  $TBS->MergeBlock('blk1,blk2,blk3','clear') ;
}
By: Kevin Minnelli
Date: 2008-05-05
Time: 18:03

Re: Load template - Form - POST Problem

Bingo - you are the man!!!
other stuff here...
$TBS->MergeBlock('blk3',$cnxid, $ps3) ;
}
else
{$TBS->MergeBlock('blk1,blk2,blk3','clear') ;}

I had tried giving those blk variables values and everything...and it turns out to be CLEAR. Sometimes things are just too simple. You just need to know where to look and in the future I will keep coming back here.

So if I spend more than 2 hours on something with no progress, I will post it up here. Thanks again for the help...

Minnelli