changing the output style.

Discussion in 'PHP' started by Zee01, Jul 5, 2010.

  1. #1
    hi..
    i am a bioscience student i have develop a database which output is shwon in coulmns. here is its coding
    ///////////////////////////////////////
    <table align="center" border="1" width="800">
    <tr>
    <td>
    <table align="center" border="1" width="100%">
    <tr bgcolor="#DADADA">
    <th>PRODUCT NAME </th>
    <th>DRUG NAME </th>
    <th>
    bio name
    </th>
    <th>
    solibiliuty
    </th>
    <th>
    drug formula
    </th>
    </tr>
    <?php

    if (isset($_GET['act']) and $_GET['act'] == 1)
    {
    $search = $_GET['search'];

    $sql_ser = "SELECT * FROM liposome WHERE drug_name LIKE '%".trim($search)."%'"; //'%.$search.%'";
    $result_ser = mysql_query($sql_ser);
    //echo mysql_num_rows($result_ser);
    if (mysql_num_rows($result_ser) > 0)
    {
    while($row = mysql_fetch_array($result_ser))
    {
    echo '
    <tr bgcolor="#FFFFFF">
    <td>
    '.$row['prod_name'].'
    </td>
    <td>
    '.$row['drug_name'].'
    </td>
    <td>
    '.$row['bio_name'].'
    </td>
    <td>
    '.$row['solibiliuty'].'
    </td>
    <td>
    '.$row['drug_formula'].'
    </td>
    </tr>
    ';
    }
    }
    }


    ?>
    </table>
    </td>
    </tr>
    </table>
    ////////////////////////////////////
    i want to display the result in that formate
    PRODUCT NAME
    result form dbn
    DRUG NAME
    rsult from the db
    BIO name
    result from the db
    solibiliuty
    result from the db
    DRUG FOMULA
    result from the db
    ////////////////////
    also when the drug formula is shwn in output then user click on it then it opens a new window containing the formula .
    and also looking for suggestions to make it more good.
    can some one help me?
     
    Zee01, Jul 5, 2010 IP
  2. Michellu

    Michellu Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I couldn't see the connection to database anywhere. I'm hoping you do it in a config.php file you include at the top of this script. It should look something like this:
    
    mysql_connect('localhost', 'username', 'password');
    
    PHP:
    of course using your database connection info.

    to put a link on the formula you would replace
    <td>
    '.$row['drug_formula'].'
    </td> 
    PHP:
    with:
    <td>
    <a href="formula.php?id='.$row['id'].'">'.$row['drug_formula'].'</a>
    </td> 
    PHP:
    granted you have a primary key named id. if not, either create it or use some other unique field.

    in formula.php file you you would extract and display only the formula corresponding to that id.
     
    Michellu, Jul 6, 2010 IP
  3. sgcoder

    sgcoder Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if u want to see the results below the header as you have mentioned, u need to modify the table slightly as
    <TR><TH>PRODUCT NAME
        <TR><TD></TD></TR>
        <TR><TH>DRUG NAME 
        <TR><TD></TD></TR>
    PHP:
    and so on........and display the results from the database.....

    However displaying in a more convenient manner would be as follows
     <TR><TD><TH>PRODUCT NAME</TD> <TD><TH>DRUG NAME </TD> 
    PHP:
    and so on....and display the subsequent results below in the table
     
    sgcoder, Jul 6, 2010 IP
  4. Zee01

    Zee01 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sir u have made drug_formula a link bt how to link it with other other file?
     
    Zee01, Jul 6, 2010 IP
  5. sgcoder

    sgcoder Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    which file do u want to link with? it opens formula.php where u need to save the formulas by id's to display accordingly.
     
    sgcoder, Jul 6, 2010 IP
  6. Zee01

    Zee01 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thnx sir. this realy help me alot.
     
    Zee01, Jul 6, 2010 IP
  7. Zee01

    Zee01 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i hv done it.it works.
     
    Zee01, Jul 6, 2010 IP
  8. Zee01

    Zee01 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    sir i try to put bt no success plz will u elaborate it?
     
    Zee01, Jul 7, 2010 IP