Jump to content

php/sql question


dmcdaniel

Recommended Posts

I have the following Code:

 

<?php
header("Cache-control: private");
header("Expires: 0");

session_start();

include('database.php');

$q = mysql_query("SELECT strName, strEmail, strFirstDay, strFirstDayDate, strLastDay, strLastDayDate FROM Vacation") or die(mysql_error());
$x=0;

echo"
<table>
<tr>
       <th>Requests</th>";

while($row = mysql_fetch_array($q)){

  extract($row);

  if ($x==0){
    echo "</tr><tr>";
  }

  $x++;

  if ($x == 3){
    $x = 0;
  }

  echo "<td>$strName, $strEmail, $strFirstDay, $strFirstDayDate, $strLastDay, $strLastDayDate</td>";
}
echo"</tr></table>";


?>

 

It formats it quite ugly. Right now it just formats it as:

 

Results

Derek McDaniel, [email protected], Monday, 05/03/2010, Tuesday, 05/04/2010 Derek McDaniel, [email protected], Monday, 05/03/2010, Tuesday, 05/04/2010 Mark Slatter, [email protected], Monday, 5/5, Friday, 5/9

Derek McDaniel, [email protected], Monday, 05/03/2010, Tuesday, 05/04/2010

 

I would like it to format like:

 

Derek McDaniel, [email protected], Monday, 05/03/2010, Tuesday, 05/04/2010

Derek McDaniel, [email protected], Monday, 05/03/2010, Tuesday, 05/04/2010

Mark Slatter, [email protected], Monday, 5/5, Friday, 5/9

Derek McDaniel, [email protected], Monday, 05/03/2010, Tuesday, 05/04/2010

 

What would I need to change in the above code? I am still new with this PHP coding and have very little experience but I am a very fast learner.

Link to comment
https://forums.phpfreaks.com/topic/200289-phpsql-question/
Share on other sites

I tried to remove the counters but it made the formatting even worse.

 

This is the new coding I tried:

 

<?php
header("Cache-control: private");
header("Expires: 0");

session_start();

include('database.php');

$q = mysql_query("SELECT strName, strEmail, strFirstDay, strFirstDayDate, strLastDay, strLastDayDate FROM Vacation") or die(mysql_error());
$x=0;

echo"
<table>
<tr>
       <th>Requests</th>";

while($row = mysql_fetch_array($q)){

  extract($row);



  echo "<td>$strName, $strEmail, $strFirstDay, $strFirstDayDate, $strLastDay, $strLastDayDate</td>";
}



?>


Link to comment
https://forums.phpfreaks.com/topic/200289-phpsql-question/#findComment-1051109
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.