www.webdeveloper.com
Results 1 to 6 of 6

Thread: Need help in table design in displaying data from database

  1. #1
    Join Date
    Oct 2011
    Posts
    350

    Need help in table design in displaying data from database

    Hi,

    I created query to display the reject acronym and reject name.

    here is my code:

    PHP Code:
      
                $sql_reject 
    "select r.reject_acro, r.reject_id, r.reject_name from process_list AS p LEFT JOIN reject_list AS r ON 
    p.reject_id = r.reject_process_id
     where p.process_name LIKE '" 
    . ($_POST["id"]) . "%'";
     
               
    $res_reject mysql_query($sql_reject);
               echo 
    "<table>";
               while(
    $row_reject mysql_fetch_assoc($res_reject)){
                   
    $acro        $row_reject['reject_acro'];
                   
    $reject_name $row_reject['reject_name'];
                
                echo 
    "<tr>";
                echo 
    "<td>$acro</td>";
                echo 
    "<td>$reject_name</td>";
                echo 
    "</tr>";     
                   
                }
               echo 
    "</table>"
    and my data in my database is this:

    reject_acro|reject_name
    AA---------Ant
    BB---------Bee
    CC---------Cat
    DD---------Dog
    EE---------Elephant
    FF---------Frog
    GG--------Goat
    HH--------Horse
    KK---------Kangaroo

    now in this code the output is the same above

    but i want it to display like this: I want to display in for columns

    AA|Ant|BB|Bee|CC|CatDD|Dog|
    EE|Elephant|FF|Frog|GG|Goat|HH|Horse
    KK|Kangaroo

    Thank you

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    550
    in "for" columns? As in 4?

  3. #3
    Join Date
    Oct 2011
    Posts
    350
    Yes 4 columns.

    Thank you

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    550
    You want to create an html table with four (4) columns in it. What is the problem here?

  5. #5
    Join Date
    Oct 2011
    Posts
    350
    In my code the output is 2 columns only.

    Thank you

  6. #6
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    550
    In your output loop add a switch. Use it like this:
    $row_started = false;
    while xxx
    {
    if (!$sw)
    {
    <tr>
    <td></td>
    <td></td>
    }
    else
    {
    <td></td>
    <td></td>
    </tr>
    }
    $row_started=!$trow_started;

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