Reputation: 631
here is my code
<?php
while($rowcall=mysql_fetch_array($qry_call))
{
?>
<table>
<tr>
<td><?php echo $rowcall['caller_id'];?></td>
<td><?php echo $rowcall['did']; ?></td>
<td><?php echo $rowcall['start_time']; ?></td>
<td><?php echo $rowcall['end_time']; ?></td>
<td><?php echo $rowcall['call_duration']; ?></td>
</tr>
</table>
<?php } ?>
I need to store this table in php variable $result.
Upvotes: 0
Views: 802
Reputation: 11
start and end the <table></table>
tag out side while loop no inside it will create a new table for every row but that's you don't want
Upvotes: 0
Reputation: 320
You could do it like this:
<?php
$result = "";
while($rowcall=mysql_fetch_array($qry_call))
{
$result .= "<table>";
$result .= "<tr>";
$result .= "<td>".$rowcall['caller_id']."</td>";
$result .= "<td>".$rowcall['did']."</td>";
$result .= "<td>".$rowcall['start_time']."</td>";
$result .= "<td>".$rowcall['end_time']."</td>";
$result .= "<td>".$rowcall['call_duration']."</td>";
$result .= "</tr>";
$result .= "</table>";
}
echo $result;
?>
Upvotes: 1
Reputation: 4046
*<?php
$result = '';
while($rowcall=mysql_fetch_array($qry_call))
{
$result .= '<table>';
$result .= '<tr>';
$result .= '<td>'.$rowcall['caller_id'].'</td>';
$result .= '<td>'.$rowcall['did'].'</td>';
$result .= '<td>'.$rowcall['start_time'].'</td>';
$result .= '<td>'.$rowcall['end_time'].'</td>';
$result .= '<td>'.$rowcall['call_duration'].'</td>';
$result .= '</tr>';
$result .= '</table>';
}
echo $result;
?>*
Upvotes: 1
Reputation: 1593
I strongly advise you to see docs at http://www.php.net/manual/en/language.types.string.php
Upvotes: 0
Reputation: 18123
Pretty basic PHP;
<?php
$result="";
while($rowcall=mysql_fetch_array($qry_call))
{
$result.=" <table>";
$result.=" <tr>";
$result.=" <td>".$rowcall['caller_id']."</td>";
$result.=" <td>".$rowcall['did']."</td>";
$result.=" <td>".$rowcall['start_time']."</td>";
$result.=" <td>".$rowcall['end_time']."</td>";
$result.=" <td>".$rowcall['call_duration']."</td>";
$result.=" </tr>";
$result.=" </table>";
}
?>
Upvotes: 1
Reputation: 3682
<?php
$result = '';
while($rowcall=mysql_fetch_array($qry_call))
{
$result .= '<table>';
$result .= '<tr>';
$result .= '<td>'.$rowcall['caller_id'].'</td>';
$result .= '<td>'.$rowcall['did'].'</td>';
$result .= '<td>'.$rowcall['start_time'].'</td>';
$result .= '<td>'.$rowcall['end_time'].'</td>';
$result .= '<td>'.$rowcall['call_duration'].'</td>';
$result .= '</tr>';
$result .= '</table>';
}
echo $result;
?>
Upvotes: 4
Reputation: 1761
Try on these lines. Also switch to mysqli_* rather than mysql_* as the one you are using is deprecated
<?php
$str="";
while($rowcall=mysql_fetch_array($qry_call))
{
$str .= "<table>
<tr>
<td>{$rowcall['caller_id']}</td>
<td>{$rowcall['did']}</td>
<td>{$rowcall['start_time']}</td>
<td>{$rowcall['end_time']}</td>
<td>{$rowcall['call_duration']}</td>
</tr>
</table>";
}
?>
Upvotes: 0