user2641435
user2641435

Reputation: 19

need to display a php sql variable value inside a php

I want the 1st line $mc1 value to display in 2nd line .

1st line :

<div id = "score_mdl"><div id = "scml"><?php echo "$mc1"; ?></div><div id = "scmlm">

2nd line :

<?php if ($mc1 == 10) {echo '<div id = "medalg"> want the value here  </div>'; }

i tried the below but no resolution yet

<?php echo $mc1 ?>
echo '$mc1'
echo "$mc1"

Upvotes: 0

Views: 44

Answers (2)

Siddharth Thevaril
Siddharth Thevaril

Reputation: 3788

Or you can use this notation -

<?php 
    if ($mc1 == 10) {
        echo "<div id = 'medalg'>{$mc1}</div>"; 
}

This reduces concatenation

Upvotes: 1

Steve
Steve

Reputation: 20469

You are looking to do string concatenation. You dont need a second echo statement:

<?php if ($mc1 == 10) {echo '<div id = "medalg">' . $mc1 . '</div>'; }

Upvotes: 4

Related Questions