Re: changing output method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try putting your print "\t$col_value\n" immediately after the foreach...

foreach ($line as $col_value)
       print "\t$col_value\n";

remember to remove teh semi-colon after the foreach line.

graeme.

chintan wrote:

as usual my database is in mysql
and there are lots of records available
i had wrote my script like this
$link = mysql_connect("localhost", "chintan","hellomysql")
    or die("Could not connect");
    mysql_select_db("chintan") or die("Could not select database");

    $query = "SELECT * FROM stockiestandbookingagents";
    $result = mysql_query($query) or die("Query failed");

    $i=0;
    while($i<mysql_num_fields($result))
        {
        echo (mysql_field_name($result, $i));
        print "\t";
        while ($line = mysql_fetch_array($result))
                    {
                    foreach ($line as $col_value);
                    }
        $i++;
        print "\t$col_value\n";
        }

    mysql_free_result($result);
    mysql_close($link);


but it just displays the pincode of the city only(the last column) the table structure is like below; +--------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+-------+ | CompanyName | varchar(50) | | PRI | | | | AddressLine1 | varchar(100) | YES | | NULL | | | AddressLine2 | varchar(100) | YES | | NULL | | | City | varchar(50) | YES | | NULL | | | PostalCode | varchar(50) | YES | | NULL | | +--------------+--------------+------+-----+---------+-------+


-- Experience is a good teacher, but she sends in terrific bills.

Minna Antrim

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux