Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    retrieving data from database

    hi

    i want to retrieve the data into local variables from database
    how can i do that?

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    There are a number of ways you can do it.

    You can do it in the SQL by using SET

    Code:
    UPDATE appointments
           SET appTitle ='$title', appTime = '$time', appDetails = '$details'
    	WHERE appDate = '$date'
    Where appTitle, appTime, and appDetails are all column names in the database.

    Or you could also use the list().
    PHP Code:
    $query "SELECT column1, column2, column3 FROM table_name";
    $result mysql_query($query);
    list(
    $col1,$col2,$col3) = mysql_fetch_row($result); 
    $col1,$col2,$col3 get there values in the order you select them from the database.
    I didn't check my code but this should work.
    Last edited by StupidRalph; 02-15-2006 at 07:05 AM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ya i got to retirve data
    but i dont know anything abt php
    first time working with this
    when will be it activated
    this is my code
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php
    mysql_connect ("localhost", "root");
    mysql_select_db(pubs);
    $name=TreeView1.SelectedNode.Text;
    $sql=mysql_query(" select * from kk1 where kname=$name");
    if (mysql_num_rows($sql))==0)
    {
    echo"Your data is not found";
    exit();
    }
    while($fet=mysql_fetch_array($sql))
    {
    $kid=$fet['kid'];
    $kname=$fet['kname'];
    $pid=$fet['pid'];
    $kdesc=$fet['kdesc'];
    }


    ?>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>

    <form id="form1" runat="server">
    <div>

    <asp:TreeView ID="TreeView1" runat="server" Height="270px" Width="247px" ShowCheckBoxes="All">
    <RootNodeStyle BorderColor="Blue" />
    </asp:TreeView>
    &nbsp;
    <asp:Label ID="Label2" runat="server" Text="Name" Width="28px"></asp:Label>
    <asp:TextBox ID="TextBox1" runat="server" Width="133px"></asp:TextBox>
    &nbsp;<br /><br />
    <asp:Button ID="Button1" runat="server" Height="35px" Text="ADD SIBLING" Width="93px" />
    <asp:Button ID="Button4" runat="server" Height="37px" Text="ADD CHILD" Width="106px" /><br /><br /><br />
    &nbsp;<asp:Label ID="Label4" runat="server" Text="Selected Item"></asp:Label>&nbsp;
    <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br /><br />
    <asp:Label ID="Label1" runat="server" Text="Description"></asp:Label>
    <asp:TextBox ID="TextBox2" runat="server" Width="335px"></asp:TextBox><br /><br /><br />
    <asp:Button ID="Button3" runat="server" Height="37px" Text="MODIFY" Width="92px" />
    <asp:Button ID="Button2" runat="server" Height="38px" Text="DELETE" Width="91px" />
    <br />
    <br />
    </div>
    </form>
    </body>
    </html>

    when node is selected in tree view the data to be displayed
    help me please
    its urgent

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Psp? Ahp?

    You're actually mixing ASP and PHP in one page? Interesting...

    I don't know a thing about ASP, but I really wonder how the server should handle this one; I'm afraid it's a recipe for disaster.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #5
    nst
    nst is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ronaldb66 is right, although in theory if the server can handle asp and php, then it should be able to do this even in one page.

    By the way, the 'mysql_connect' should have a variable for the password too.

    I quote from the php manual
    Code:
    <?php
    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
       die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>
    Are you sure the server is MySql and not MsSql?

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you work out if you are using PHP or ASP then here is a PHP/mySQL tutorial
    http://www.zend.com/php/beginners/php101-8.php#Heading4


  •  

    Posting Permissions

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