Vladimir Stus
Vladimir Stus

Reputation: 75

Double vs SIngle Quotes issue

Can someone help me to write this correct, i am strugling. And could someone explain to me how to combine single and double quotes in best way??? I have issue in line

value = "<?php echo $client['name_'.$key];?>"

my whole code is

<?php
    foreach($this->config->item('languages') as $key=>$value)
    {
        echo '<div id="edit-fragment-'.$key.'">
        <table class="form_horizontal" width="100%">

        <tr>
            <td class="field">'.lang('polls_txt_title').'</td>
            <td class="value"><input type="text" name="client_'.$key.'" value = "<?php echo $client['name_'.$key];?>"; /></td>
        </tr>

        <tr>
            <td class="field">'.lang('polls_txt_vote').'</td>
            <td class="value"><input type="text" name="polls_'.$key.'_vote" value="'.$this->mConfig->item('polls_'.$key.'_vote').'" /></td>
        </tr>



        </table>
        </div>';
    }
    ?>

Upvotes: 1

Views: 62

Answers (4)

Daryl Gill
Daryl Gill

Reputation: 5524

Change to:

value = "<?php echo $client['name_'.$key]; ?>"

or if short tags are enabled

value = "<?=$client['name_'.$key];?>"

Upvotes: -2

GautamD31
GautamD31

Reputation: 28763

Try like

value = "<?php echo $client['name_'.$key];?>";

As per your edited question see my second answer

'<td class="value"><input type="text" name="client_'.$key.'" value = "'.$client['name_'.$key].'" /></td>'

Upvotes: 3

Kolja
Kolja

Reputation: 868

Your HTML is <input value="" />

Your PHP is <?php echo $client["name_" . $key];?>

Together it'd be <input value="<?php echo $client["name_" . $key];?>" />

Your problem is incorrect php syntax in your code. With the correct syntax you don't even need different (i.e. both double and single) quotes.

Upvotes: 0

benomatis
benomatis

Reputation: 5643

You could do either...

<input value="<?php echo $client['name_'.$key]; ?>" />

...or...

<?php echo "<input value=".$client['name_'.$key]." />"; ?>

Upvotes: 1

Related Questions