Results 1 to 2 of 2

Thread: output the data into each different tags

  1. #1
    Join Date
    Sep 2008

    output the data into each different tags

    Hi guys,

    I have stored data in a MySQL database and I've output it in PHP. I want to know how I can output the data in different <span id="text1">` tags from `<tr><td>` tags.

    PHP Code:
    $errmsg_arr = array();
    $errflag false;
    $link mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
    'Failed to connect to server: ' mysql_error());
    $db mysql_select_db(DB_DATABASE);
    "Unable to select database");
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    implode('<br />',$errmsg_arr);
    $qrytable1="SELECT id, mydata FROM mydb ";
    $result1=mysql_query($qrytable1) or die('Error:<br />' $qry '<br />' mysql_error());
             while (
    $row mysql_fetch_array($result1))
    On my PHP page it show something like this:

    PHP Code:
        <tr><td>my data 1</td></tr><tr><td>my data 2</td></tr><tr><td>my data 3</td></tr><tr><td>my data 4</td></tr
    How can I split the output the data into an array before I could output them in different <span id="text1">` tags from `<tr><td>` tags?

    any advice would be much appreicated.

    thanks in advance

  2. #2
    Join Date
    Apr 2013

    You can switch in your while statement this:
    echo "<tr><td>".$row['mydata']."</td></tr>";

    with this:
    echo "<span class='text1'>".$row['mydata']."</span>";

    You would also need to remove <table></table> tags, since they are no longer needed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles