Results 1 to 2 of 2

Thread: php Help?

  1. #1
    pakilala is offline Junior Member
    Last Online
    3rd July 2011 @ 03:03 PM
    Join Date
    16 Jan 2006
    Posts
    16
    Threads
    8
    Credits
    0
    Thanked
    0

    Default php Help?

    I have mysql database name "prj" which has two fields id & amount

    i want to display the amount field in php and with S#.

    like that

    S# Amount
    1. 7800
    2. 5200
    3. 7400
    .
    .
    .
    10 5369

    How it is possible that i can add S# in php page.

    plz help me because me in trouble

    regards.


    Adil

  2. #2
    Join Date
    08 Feb 2009
    Location
    Abbottabad
    Posts
    291
    Threads
    23
    Thanked
    4

    Default

    here comes the php code you can save it as anyname.php

    <?php
    $con = mysql_connect("localhost","prj","dbpassword");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("my_db", $con);

    $result = mysql_query("SELECT * FROM table_name");

    while($row = mysql_fetch_array($result))
    {
    echo $row['id'] . " " . $row['amount'];
    echo "<br />";
    }

    mysql_close($con);
    ?>


    The following example selects all the data stored in the "price" table (The * character selects all the data in the table

    table_name is a name of the table where your fields (ID & amount are stored) plz change it as you required

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •