Jump to content

for loop and explode help


1989gta

Recommended Posts

I’m running into a problem when writing my page what I want is to run a query that will pull a list of application names, echo the first application name in the query. The next query will run using that application name pull a count and then echo the count to the page then loop and start all over again with the next app and count. For some reason I can’t get it to work.

 

 

<?

echo "<table border=1>";

 

    echo "<tr>";

      echo "<td>Application</td>";

      echo "<td bgcolor=#f8f3df>Todays Totals</td>";

    echo "</tr>";

 

 

///////////////////////////////////application/////////////////////////////////   

$query = "SELECT app_name,install_date FROM tbl where app_name <> ''";

 

$result = mssql_query ($query);

while($line = mssql_fetch_array($result)){

  echo "<tr border=1>";

$app =$line[0];

 

/////////////////////////////////////todays totals///////////////////////////// 

////////////////////////////////////pull current date//////////////////////////

$current_date = date('m-d-y');

$query = "select count(*)

            from  conversions where date_current ='$current_date' and package_name='$app'";

      $result = mssql_query ($query);

while($line = mssql_fetch_array($result)){

    $todays_count = $line[0];

 

$test = explode(",","$app");

    for ($i=0; $i < Count($test); $i++) {

    echo "<td nowrap>"; 

    echo"$test[$i]";

    echo "</td>";

}

}

}     

echo "</tr>";

 

echo "</table>";

 

?>

 

 

With this I’m just trying to echo all the application names but as soon as I add the explode and loop it only echos the first app so i'm lost.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.