Martin
Martin

Reputation: 49

Two values in the same column

I have two columns with different values:

enter image description here

And I need to echo those two values into one column, like that:

IP is brackets

Printing method:

if($result->num_rows > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        echo '<tr>
              <td scope="row">' . $row["id"].'</td>
              <td>' . $row["data"] .'</td>
              <td>' . $row["ip"] .'</td>
              </tr>';
    }
}

Any suggestions on how I could do that?

Upvotes: 1

Views: 37

Answers (2)

RiggsFolly
RiggsFolly

Reputation: 94662

Do you mean like this

echo '<tr>
        <td scope="row">' . $row["id"].'</td>
        <td>' . $row["data"] . '(' . $row["ip"] . ')</td>
      </tr>';

Upvotes: 1

Racil Hilan
Racil Hilan

Reputation: 25351

Merge the two cells:

<td>' . $row["data"] .'</td>
<td>' . $row["ip"] .'</td>

Into one:

<td>' . $row["data"] . '(' . $row["ip"] . ')</td>

Upvotes: 0

Related Questions