Jump to content

Recommended Posts

Hi,

I want to display row 0   row 2  row 3 and row 4 values in to text field.this is my code.but it's display "Undefined offset: 1 in C:\wamp\www\member\sys-admin\groups.php on line 15 ,Undefined offset: 2 in C:\wamp\www\member\sys-admin\groups.php on line 16 ,Undefined offset: 3 in C:\wamp\www\member\sys-admin\groups.php on line 17".

 

  



      <?php
            $r_sql = "SELECT ugroup FROM ugroups ";
            $r_result = db::getInstance()->query($r_sql);
            $row = $r_result->fetch(PDO::FETCH_NUM);
            
            $g1 = $row['0'];
            $g2 = $row[1];
                 $g3 = $row[2];
                 $g4 = $row[3];
        ?>


 

html

 

    


<strong>G 1</strong><input name="g1" type="text" id="g1" style="width:300px;" value="<?php echo $g1;  ?>" />
<strong>G 2</strong>    <input name="g2" type="text" id="g2" style="width:300px;" value="<?php echo $g2;  ?>" />
<strong>G 3</strong><input name="g3" type="text" id="g3" style="width:300px;" value="<?php echo $g3;  ?>" />
<strong>G 4</strong><input name="g4" type="text" id="g4" style="width:300px;" value="<?php echo $g4;  ?>" />

post-170830-0-85925200-1412664118_thumb.jpg

given that in your previous threads on this forum, you successfully used a mysql_ fetch statement in a while(){} loop to loop over the rows that a query returned, why not try that same method now? just because you changed from using the mysql_ functions to PDO functions doesn't mean that the fundamental concepts used in the php code changed too.

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.