试图在一个+中组合多个php变量,包括html无法正常工作

This is what I'm trying to do:

Trying to change this from:

echo "<tr><td>".$name."</td><td>".$row["Price"]."</td><td>".$kkk." | ".$res3."</td><td>".$cash." | ".$cash2."</td><td>".$loss."</td><td>".$url."</td></tr>";

To a string I can change at ease:

$dbtable = '<tr><td>' .$name. '</td><td>' .$row["Price"]. '</td><td>' .$kkk. ' | ' .$res3. '</td><td>' .$cash. ' | ' .$cash2. '</td><td>' .$loss. '</td><td>' .$url. '</td></tr>';

so I can echo like this:

echo $dbtable;

but my solution isn't working. What am I doing wrong?

Also, I tried putting each "" as a variable as well, but it still prints blank.

Its all about quotes.. Doubles and Singles..

echo "<tr><td>".$name."</td><td>".$row['Price']."</td><td>".$kkk." | ".$res3."</td><td>".$cash." | ".$cash2."</td><td>".$loss."</td><td>".$url."</td></tr>";

In your first example, modified above, double-quotes are the string-delimiters (they surround the HTML) so cannot be used inside PHP variables..

Also, PHP variables inside double-quotes will be 'evaluated', so do not need to be quoted (unless they contain an array element that requires its own quotes).

So your example, modified again could also be:

echo "<tr><td>$name</td><td>".$row['Price']."</td><td>$kkk | $res3 </td><td>$cash | $cash2</td><td>$loss</td><td>$url</td></tr>";

Your second example should work fine. And, Yes - saving the string to a variable is correct.

Quotes doesn't matter for html elements. All look's fine to me.
May be you check console and see no result, try to view source
try this

$dbtable = '<table>';
$dbtable .= '<tr><td>' .$name. '</td><td>' .$row["Price"]. '</td><td>' .$kkk. ' | ' .$res3. '</td><td>' .$cash. ' | ' .$cash2. '</td><td>' .$loss. '</td><td>' .$url. '</td></tr>';
$dbtable .= '</table>';