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

Link to comment
Share on other sites

<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

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.