Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the script

Status
Not open for further replies.

nicktan

Programmer
Joined
Dec 9, 2002
Messages
3
Location
AU
I need help with scripting. This is the script currently used:

<?
$query = &quot;select * from vacancy_rego&quot;;
include(&quot;../classes/database.php&quot;);
$database = new database();
$result=$database->openConnectionWithReturn($query);
while ($row = mysql_fetch_assoc($result))
{
echo &quot;</br>&quot;;
$first = true;
foreach ($row as $name =>$col)
{
if (!$first)
echo &quot; | &quot;;
echo &quot;$name = $col&quot;;
$first = false;
}
echo &quot;</br>&quot;;
}
?>

What happens with this script is that it return the data as show below:

id = 1 | postcode = 3000 | source = A
id = 2 | postcode = 3001 | source = B
etc

BUT I would like the data to be returned in the following format:

id | postcode | source
1 | 3000 | A
2 | 3001 | B

Can someone please help to modify the script above to fulfill the last display format.

THANKS
 
But what happens if there are so many fields? Do I still have to hard code the field name in one by one?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top