View Full Version : retrieving data from database

02-15-2006, 07:23 AM

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

02-15-2006, 08:02 AM
There are a number of ways you can do it.

You can do it in the SQL by using SET

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().

$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.

02-15-2006, 08:24 AM
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">
mysql_connect ("localhost", "root");
$sql=mysql_query(" select * from kk1 where kname=$name");
if (mysql_num_rows($sql))==0)
echo"Your data is not found";

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

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

<asp:TreeView ID="TreeView1" runat="server" Height="270px" Width="247px" ShowCheckBoxes="All">
<RootNodeStyle BorderColor="Blue" />
<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 />

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

02-16-2006, 01:56 PM
You're actually mixing ASP and PHP in one page? Interesting... :eek:

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.

02-16-2006, 02:08 PM
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

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
echo 'Connected successfully';

Are you sure the server is MySql and not MsSql?

02-16-2006, 03:01 PM
If you work out if you are using PHP or ASP then here is a PHP/mySQL tutorial

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum