Thanks sir it works

Sir,

I have following codes

<?php
$country="";
$capital="";
if (isset($_POST['submit']))
{
$country=$_POST['text1'];
$capital=$_POST['text2'];
echo '<script type="text/javascript">alert("The capital of " .$country. "is " . $capital)</script>';
}

if (isset($_POST['clear']))
{
$country="";
$capital="";
}
?>

<html>
<head><title>Result on same page</title>
</head>
<body>
<center>
<form name="form1" action="same_browser.php" method="post">
Country<input type="text" name="text1" value="<?php echo $country;?>"><br>
Capital<input type="text" name="text2" value="<?php echo $capital;?>"><br><br>
<input type="submit" name="submit" value="Show Result">
<input type="submit" name="clear" value="clear">
</form>
</center>
</body>
</html>

Thes does not work, please help me to locate where are errors?

It does not run this line of code

echo '<script type="text/javascript">alert("The capital of " .$country. "is " . $capital)</script>';

Thanks

Dear Sir,

I have following codes

<?php
$var2="";
$name="";
if (isset($_POST['button1']) && !empty($_POST['text1'])) {
$name=$_POST['text1'];
if ($name=="1") {
$var2="1";
}else{
$var2="0";
}
}
?>

<html>
  <head>
    <title>
      First form
    </title>
  </head>
    <body>  
    <form name="aa" action="textboxes.php" method="Post">
      First<input type="text" name="text1" value=""><br>
      Second<input type="text" name="text2" value="<? echo $var2; ?>" disabled><br>
      <input  type="submit" value="Display" name="button1">
    </form>
    </body>
</html>

If I enter 1 in text1 then text2 must show 1 else text2 must show 0

Please see what is wrong in my codes.

Thanks

Thanks now it works as i wish

Sir on this line

if (isset($_POST['button1']))&& !empty($_POST['text1']){

it says:
Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in C:\wamp\www\Test\jiml.php on line 2

how to get rid of it?

Dear Sir,
I have modified your codes once again as

  <?php
  if (isset($_POST['button1'])){
  $name=$_POST['text1'];
  }else{
  $name="";     
  }

  if ($name) {
  echo 'My name is ' . $name;
 }else{
 echo 'No name entered';
 }
 ?>

 <html>
   <head>
     <title>
       First form
     </title>
   </head>

   <body>

     <form name="aa" method="POST">
       Name
       <input type="text" name="text1" value="">
       <input  type="submit" value="Display" name="button1">
     </form>

   </body>

 </html>

It has no error, I need little modification again.
When I load page it says:

No name entered

When I press Display button then it must run following codes

<?php
if (isset($_POST['button1']))&& !empty($_POST['text1']){
    $name=$_POST['text'];
if ($name) {
echo 'My name is ' . $name;
}else{
echo 'No name was Entered';
}
}
?>

Why it runs above codes without pressing Display Button?

MR SAMIR IBRAHIM FROM LEBANON Has given the correct answer as

[CODE]Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
If Len(DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value) = 7 Then

            str = "SELECT desc1,weight FROM master where code =" & Val(DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value)
            dt = GetTable(str)
            Dim myCell As DataGridViewCell = DataGridView1.CurrentCell

            If dt.Rows.Count > 0 Then
                DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value = (IIf(IsDBNull(dt.Rows(0).Item("desc1")), "", dt.Rows(0).Item("desc1")))
                DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(2).Value = (IIf(IsDBNull(dt.Rows(0).Item("weight")), "0", dt.Rows(0).Item("weight")))
            Else
                MsgBox("Code Not Found", MsgBoxStyle.Information)
                SendKeys.Send("{left}")
                ' SendKeys.Send("{UP}")
                DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value = Nothing
            End If

        Else
            MsgBox("Wrong Code", MsgBoxStyle.Information)
            SendKeys.Send("{left}")
            DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value = Nothing
        End If
    End If

End Sub[/CODE]

So all credite goes to him

[QUOTE=adatapost;1115182][b]>But I want to add a 3rd column city type char(80).[/b]
DataTable.Columns.Add method.
[code]
dt2.Columns.Add("City")
da2.Fill(dt2)
[/code][/QUOTE]

ok that works but in following codes

[CODE] str = "SELECT RANK() OVER(ORDER BY acccode) AS sno,count(acccode) as sno,acccode,COUNT(Date) AS vou_no, SUM(Qty) AS Qty, SUM(Qty*weight) AS weight FROM gpass where Date between '" & Me.dtp_first.Text & "' and '" & Me.dtp_last.Text & "' GROUP BY acccode"
dt = GetTable(str)
dt.Columns.Add("tittle")

        Dim cmd As New SqlClient.SqlCommand("UPDATE dt SET tittle=(SELECT top 1 desc1 FROM master WHERE master.code=dt.acccode)", con)
        cmd.ExecuteNonQuery()

[/CODE]

the error message appears
invalid object name 'dt'.

How to add datatable reference in Update statement?

I have following codes

[CODE] str2 = "select sno,name from employees where sno =" & Val(Me.TextBox1.Text)
cmd2 = New SqlClient.SqlCommand(str2, con)
da2 = New SqlClient.SqlDataAdapter(cmd2)
dt2 = New DataTable
da2.Fill(dt2)[/CODE]

Now dt2 has two columns as sno and name
But I want to add a 3rd column city type char(80)

Please help

[QUOTE=adatapost;1115092][code]
IF Not IsNothing(currCell) Then
If currCell.Value.ToString().Length = 0 Then
e.Handled = True
DataGridView1.CurrentCell = DataGridView1.Item(currCell.ColumnIndex, currCell.RowIndex)
End If
End If
[/code][/QUOTE]

on this line
If currCell.Value.ToString().Length = 0 Then

it says
Object reference not set to an instance of an object.

[QUOTE=adatapost;1115060][code]
Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
Dim currCell As DataGridViewCell = DataGridView1.CurrentCell
If currCell.Value.ToString().Length = 0 Then
e.Handled = True
DataGridView1.CurrentCell = DataGridView1.Item(currCell.ColumnIndex, currCell.RowIndex)
End If
End Sub
[/code][/QUOTE]

When columnindex=0 is 0 then
it has following error

[QUOTE=padtes;1114074]Given relational database normalization, you should not do that. What you do is join Sale and Code tables in your select statement.
However for some reason you do want to update the SALE table, just for sake of it here is SQL that works in MS SQL. Nothing to do with VB.net (though you can execute Non Query)
[code=SQL]
Update Sale set product=(select top 1 product from Code where code.code=sale.code)
[/code]
And last, Why won't you call these tables as Product and Sales? A code table with Code column? I am sure you are just a student. No programming professsional will use this naming convention.[/QUOTE]

The cammad says

Comma, ')' or valid expression continuation expected

[QUOTE=adatapost;1114919][b]>Should I change code or choose some other datagridview event?[/b]

Yes. Think about [URL="

Dear Developers

SQL, Table1 has data as following

Code------product
1-----------Mango
2-----------Potato
3-----------Orange

Datagridview has THREE columns as

Code----product-------qty

I have following codes
[CODE]str3 = "SELECT product FROM table where code =" & Val(DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value)
dt3 = GetTable3(str3)

    If dt3.Rows.Count > 0 Then
        DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value = (IIf(IsDBNull(dt3.Rows(0).Item("product")), "", dt3.Rows(0).Item("product")))
                Else
        MsgBox("Code Not Found", MsgBoxStyle.Information)
    End If

[/CODE]

If code not found then msgbox appears and cursor moves to NEXT COLUMN. That works fine

But I want ......

When code not found then cursor MUST NOT GO TO NEXT COLUMN. It should remain there until it found value from Table1.

Should I change code or choose some other datagridview event?

Please help

What is the best datagridview event to use these codes

I want to check column 0 is empty or has some value

[CODE]If e.ColumnIndex = 0 Then
If DataGridView1.CurrentCell.Value = "" Then
MsgBox("Empty Value")
Else
MsgBox("Not empty column")
End If
End If[/CODE]

Please help

Dears

[CODE]
Private Sub DataGridView1_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
If e.ColumnIndex = 0 And e.RowIndex = 0 Then
MsgBox("this is first coulmn")
End IfEnd Sub
[/CODE]
IF cursor leaves column 0 and row 0 then it displays msgbox but
I want to check where column 0 and row 0 has value or empty

In case of empty cell it must display msg as
msgbox("this is empty cell")

Please help

Hello good Teachers

I have a datagridview with 3 columns. the second column is a read only . When I leave column 1 I would like to go directly to column 3.

For this, I got following codes from somewhere but I need these codes in vb.net format, please help or suggest some other method

[CODE]Code Snippet
void dataGridView1_KeyDown(object sender, KeyEventArgs e)

    {

        if (e.KeyData == Keys.Tab)

        {

            if (this.dataGridView1.CurrentCell.ColumnIndex == 0)

            {

                this.dataGridView1.CurrentCell = this.dataGridView1[2, this.dataGridView1.CurrentCell.RowIndex];

                e.Handled = true;

            }

        }

    }

[/CODE]

[QUOTE=itzshaheer;1109220]When I type some data on text box and click the button 'Save' in db only storing the word in the SQL command like like that. There is no error messages . What you think. Can you help me[/QUOTE]

Is there any error message?

Hello

Sqlserver MyTable has following data

Vou---------date---------qty
1-------25/12/2009------5
2-------25/12/2009------4
1-------26/12/2009------8
2-------26/12/2009------3
3-------26/12/2009------2

[CODE]
str = "SELECT date, SUM(Qty) AS Qty, FROM mytable GROUP BY Date"
dt = GetTable(str)
[/CODE]

These codes display following result

date--------------qty
25/12/2009------9
26/12/2009------13

Now I want to add sno column in result as

Sno--------date---------qty
1------25/12/2009------9
2------26/12/2009------13

What command should in str command to get above result

Please help

Dear Developers

How to enable "Autio Hide" command for Solution Explorer Window

Please Help

Hello Everyone

Sqlserver Table1 has following data

Sno---------date---------qty
1-------25/12/2009------5
2-------25/12/2009------4
1-------26/12/2009------8
2-------26/12/2009------3
3-------26/12/2009------2

I want to get following result

Sno---------date---------qty
2-------25/12/2009------9
3-------26/12/2009------13

That is grouping on date.
Column1 =count date
Column2 =date
Column3=sum of qty

What command should I write to get above result

Please help

Datagridview has three columns as

code-----name------country
1--------Eric--------Germany
2---------Bill--------France

I want to apply code like these
[CODE] If e.ColumnIndex = 2 Or e.KeyValue = Keys.Left Then
SendKeys.Send("{RightArrow}")
End If
[/CODE]

These are not correct codes, I need modification
Reason:

When cursor is in column3 (country) and user press LEFT arrow key then cursor must move to column 0 (code)

I want to skip column1 (name)

Please help