Adding a <br/> after loop section has ran
I am using the following code.
<?php
//DB CONNECTION
$ROWS = "id,f开发者_高级运维irstname,lastname";
// explode at the comma and insert into an array
$test = explode("," , $ROWS);
//adds array test to the var sam
$sam = array($test);
// querys the database
$new = mysql_query("SELECT * FROM {$DB_TABLE}");
// while loop to loop through selected fields
while ($row = mysql_fetch_array($new)) {
foreach ($sam[0] as $v) {
echo $row[$v] . $DELIMITER . "<br />";
}
}
?>
I get the following results.
834(|)
Steph(|)
Thompson(|)
835(|)
Lucy(|)
kim(|)
836(|)
Iwan(|)
Will(|)
837(|)
Sarah (|)
Good(|)
The problem I have is the <br>
tag. Where do I put it? Because I need it to output like this (like it shows in the $ROWS variable above $ROWS = "id,firstname,lastname";
)
834(|)Step(|)Thompson(|)
835(|)Lucy(|)kim(|)
836(|)Iwan(|)Will(|)
837(|)Sarah (|)Good(|)
Where do I add the <br>
tag?
TRY
while ($row = mysql_fetch_array($new)) {
foreach ($sam[0] as $v) {
echo $row[$v] . $DELIMITER;
}
echo "<br />";
}
精彩评论