Forum Moderators: coopster

Message Too Old, No Replies

php explode function.

         

nanat

8:29 am on Oct 14, 2009 (gmt 0)

10+ Year Member




$result = mssql_query("select t0.*, t1.Lname, t1.GroupID from HB1group t0 inner join HB1location t1 on t0.GID = t1.GroupID and t1.GroupID ='$GroupID'");

$exist = 6;

$counts = 1;
if($exist > 0)
{
for ($i = 0; $i < $exist; $i++)
{
$Lname = mssql_result($result, $i, "Lname");

echo '<th><h1 class="flue">'.$Lname.'</h1></th>';
$pieces = print_r(explode(" ", $counts));

$zero[0];
$one[1];
$two[2];
$tree[3];
$four[4];
$five[5];
$counts++ ;
}

}
else
{
echo '<h1 class="flue">NO Entry</h1>';

}



return:
Array ( [0] => 1 ) Array ( [0] => 2 ) Array ( [0] => 3 ) Array ( [0] => 4 ) Array ( [0] => 5 ) Array ( [0] => 6 )

this sequence doesnt work because no separator

my question is how can i put "," in order me to get the value of 1,2,3,4,5,6 so that my function explode work..

return:


Array ( [1] => 1 ) Array ( [2] => 2 ) Array ( [3] => 3 ) Array ( [4] => 4 ) Array ( [5] => 5 ) Array ( [6] => 6 )

tnx ^^

TheMadScientist

9:38 am on Oct 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I really can't see how you're thinking what you have posted for an array of arrays will work at all, because it's structured wrong, even if you add the comas and get the structure correct it will not work with explode like you would like (I just tested to make sure), and really it looks to me like you're trying to explode your counter?

$counts = 1;
if($exist > 0)
{
for ($i = 0; $i < $exist; $i++)
{
$Lname = mssql_result($result, $i, "Lname");

echo '<th><h1 class="flue">'.$Lname.'</h1></th>';
$pieces = print_r(explode(" ", $counts));

I think you are going to have to find a different solution to your issue.

nanat

11:43 am on Oct 15, 2009 (gmt 0)

10+ Year Member



Yeah.. i want to explode a counter base in my loops.. the propose the the explode is to store a value total..

for example:
for by 3
one_two_tree
1_2_3
1_2_3
total horizontal 2_4_6
total Vertical 6_6
total H+v = 24

there no problem about the vertical total i figure it out but its so hard for me to get the horizontal because my horizontal value is not fix


<?php

$resultz = mssql_query("select * from vessel");
$col = mssql_num_rows($resultz);

if($col > 0)
{
for($b=0; $b < $col; $b++)
{
$WeekID= mssql_result($resultz, $b, "WeekID");
$VesselName = mssql_result($resultz, $b, "VesselName");

echo '<tr>';
echo '<td id="info"><b>'.$VesselName.'<b></td>';

$sum = 0;

$resulta = mssql_query("select t0.*, t1.* from TTransactionTable t0
inner join HB1location t1 on t1.LocationID = t0.Grouping where t0.VID=".$WeekID." and t0.Groupid = '$GroupID' and t0.WeekNo = '$week' and t0.GetDate = '$fromdate'");
$row = mssql_num_rows($resulta);

if($row > 0)
{
for($c=0; $c < $row; $c++)
{
$inputTable= mssql_result($resulta, $c , "inputTable");
$sum = $sum + $inputTable;

if (($c%2) == 0)
{
$css = ' bgcolor="#E4E4E4"';
}
else
{
$css = 'bgcolor="#D5F1D0"';
}

echo '<td '.$css.' id="number">'.$inputTable.'</td>';

}

echo '<td id="total">'.$sum.'</td>';
echo '</tr>';

}
else
{
echo '';
}
}
}
else
{
echo '<h1>NO POSTED YET</h1>';
}


?>