1. Hey Guest Did you know you can win an Honor 10 phone worth ₹33,000 and an additional ₹70,000 in paytm vouchers, just by replying to some threads and taking part in the discussions happening in the Honor Hub?

    What are you waiting for? Start commenting and start winning! Remember to read the instructions posted here.

    Dismiss Notice

How to retrive data from mysql database dynamically

Discussion in 'QnA (read only)' started by Butterfly, Nov 3, 2004.

Thread Status:
Not open for further replies.
  1. Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Folks ,

    I tried Dreamweaver MX 2004 to do it automatically, that coroupted my whole site..

    So , can u plz write me one code for me , all i wanted is i have already stored data in the database , now what i want is to show that data in the web page dynamically, like say dynamic table !

    can u u show me how and if possible plz give me a full php coding for retriving data from databse..

    thanks
     
  2. ishaan

    ishaan New Member

    Joined:
    Feb 28, 2004
    Messages:
    894
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    New Delhi
  3. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    i had given you the code in your last post i suppose..

    need to use the same code to fetch the records and display the stuff in while loop...

    Deep
     
  4. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Well,

    If i were damn expert in it i would have not post it in the froum...well yeah Deep u did post it last time , but u dinbt post it all , somne parts are blank, and thats a difficult for me to add..

    never mind

    thanks a lot
     
  5. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    Code:
    <?php
    mysql_connect ($host,$user,$pass);
    mysql_connect_db ($database);
    
    $sql = "SELECT id,image_path,image_description FROM pic";
    $result = mysql_query ($sql);
    
    while ($row = mysql_fetch_row($result))
    {
    
    $id = $row[0];
    $image_path = $row[1];
    $image_description = $row[2];
    
    $show_stuff .= "<img src=\"$image_path\">
    $image_description";
    
    // ^^^ this will store all the values of table inside $show_stuff ^^^
    }
    
    echo $show_stuff;
    ?>
    
    all done...
    this is just basic..you need to customize it and add into your code according to your needs...

    Regards
    Deep
     
  6. prakashaka

    prakashaka New Member

    Joined:
    Aug 12, 2004
    Messages:
    35
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mangalore
    is it work if v dont have sql server connection in our web site?
    deeeeeeeep?
     
  7. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    you need mysql server for that...

    connection you have to make it using the code i specified about...

    Deep
     
  8. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Hellow Friends ,
    This is the code am trying : have a look am getting error, if u all can fixed it up for me :

    am getting error on this line : Parse error: parse error in c:\web\test.php on line 12

    ***************************************************
    <html><body>

    <?
    $host = "localhost";
    $user = "root";
    $pass = "";
    $dbname = "karmas";
    $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."
    ");
    mysql_select_db($dbname)

    $sql = "SELECT ID,logo,Description FROM client";
    $result = mysql_query ($sql);



    while ($row = mysql_fetch_row($result))
    {

    $ID = $row[0];
    $logo = $row[1];
    $Description = $row[2];

    $show_stuff .= "<img src=\"$image_path\">
    $image_description";

    // ^^^ this will store all the values of table inside $show_stuff ^^^
    }

    echo $show_stuff;
    ?>
    </body></html>

    ************************************************

    My Table structure (karmas)

    ¦ID¦logo¦Description¦

    *****************************************************
    Parse error: parse error in c:\web\test.php on line 12

    ($sql = "SELECT ID,logo,Description FROM client"; )

    :)
     
  9. Deep

    Deep Version 2.0

    Joined:
    Jan 23, 2004
    Messages:
    977
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mumbai
    mysql_select_db($dbname)

    should be

    mysql_select_db($dbname) ;

    Deep
     
  10. OP
    OP
    Butterfly

    Butterfly New Member

    Joined:
    Sep 20, 2004
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Thimphu
    Thanks Deep,

    It finally worked , i like it ,...... something not yet arranged ..

    cant the data be in dynamic table , so that what ever i retrive it from the datbase it directly show it in table in the browser ..

    Let me know more

    thnaks
     
Thread Status:
Not open for further replies.

Share This Page