开发者

Adding a <br/> after loop section has ran

开发者 https://www.devze.com 2023-02-15 19:52 出处:网络
I am using the following code. <?php //DB CONNECTION $ROWS = \"id,f开发者_高级运维irstname,lastname\";

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 />";

}
0

精彩评论

暂无评论...
验证码 换一张
取 消