Jump to content

problem with foreach


iamq08

Recommended Posts

I'm trying to populate a form in a menu for my website, and for some reason it won't pull the information from the database correctly. Any assistance would be real helpful.

here's the function from the include file

[code]  function get_extensions(){
                $q = mysql_query("select name, context, mailbox, secret from extensions");
                while($info = mysql_fetch_array($q)){
                return $info;
                }
        }[/code]


Heres the excerpt from the php file
[code]
$vars = New Casename;
$vars->mysqldbcon();
$extens = $vars->get_extensions();
..............
................
<?
                foreach($extens as $val){
        ?>

<form action="user.php" method="POST">
                <tr bgcolor="#E7F3FB">
                      <td nowrap valign=top><input name="name" value="<?=$val['name']?>"></td>
                      <td nowrap valign=top><input type="text" maxlength="150" name="context" value="<?=$val['context']?>"></td>
                      <td nowrap valign=top><input type="text" maxlength="150" name="mailbox" value="<?=$val['mailbox']?>"></td>
                      <td nowrap valign=top><input type="text" maxlength="150" name="secret" value="<?=$val['secret']?>"></td>
                          <td nowrap valign=top><input type="Submit" name="action" value="Update"></td>
                      <td nowrap valign=top><input type="Submit" value="Remove" name="action"></td>
                </tr>
</form>
<?}?>[/code]

For some reason it doesn't pull the information correctly.
Link to comment
https://forums.phpfreaks.com/topic/15006-problem-with-foreach/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.