Jump to content

Trying to get this loop to return all the records


sdm

Recommended Posts

I'm trying to get the database to return all the records and format them into table cells, this only outputs the first one.

 

How do I format this so that it puts all sets into table before stopping the loop please.

 

This is the code I currently have:

 

<?

include("dbconnect.php");

$getnews = mysql_query("select * from news ORDER BY id DESC");

while($r=mysql_fetch_array($getnews)){

extract($r);

/* echo("<b>$title on $date<BR><BR>$sector<BR><BR>$location<BR><BR>$salary<BR><BR>$details</b><BR><BR>"); */

 

}

?>

 

<div align="center">

<table width="643" border="1" cellspacing="1" cellpadding="1">

<tr>

<td width="153"><?php print $title;?></td>

<td width="198"><?php print $sector;?></td>

<td width="122"><?php print $location;?></td>

<td width="147"><?php print $salary?></td>

</tr>

<tr>

<td>Description</td>

<td colspan="3"><?php print $details;?></td>

</tr>

</table>

</div>

 

Thanks for your time.

 

SDM

<div align="center">
<table width="643" border="1" cellspacing="1" cellpadding="1">
<?php
include("dbconnect.php");
$getnews = mysql_query("select * from news ORDER BY id DESC");
while($r=mysql_fetch_array($getnews)){
extract($r);
?>
<tr>
<td width="153"><?php print $title;?></td>
<td width="198"><?php print $sector;?></td>
<td width="122"><?php print $location;?></td>
<td width="147"><?php print $salary?></td>
</tr>
<tr>
<td>Description</td>
<td colspan="3"><?php print $details;?></td>
</tr>
<?php
}
?>
</table>
</div>

 

Ray

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.