Hello there, Can anyone help me in my problem? My problem is, i need to display a record in the textbox, but it's not working. the record(database) and the textboxes.

Thanks :D

Could you please give us the code so we can try and resolve your issue :)

Sorry, Here's my code. Thanks

<?php

$empno = $_POST['txtempno']; 
$empname = $_POST['txtename'];
$position = $_POST['txtpos']; 
$salary = $_POST['txtsal']; 
$aname=$_POST['txtaname'];
$address=$_POST['txtadd'];
$relation=$_POST['txtremp'];
$age=$_POST['txtage'];
$sss=$_POST['txtsss'];
$ph=$_POST['txtph'];
$pagibig=$_POST['txtpagibig'];
$tax=$_POST['txttax'];
$total=$_POST['txttotal'];
$sss2=$_POST['txtsss2'];
$ph2=$_POST['txtph2'];
$pagibig2=$_POST['txtpagibig2'];
$tax2=$_POST['txttax2'];
$total2=$_POST['txttotal2'];
$tded=$_POST['txttded'];
$tsal=$_POST['txttsal'];
$allotment=$_POST['txtallotment']; 

		$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
		@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
		$query="SELECT * FROM `profiles`";
		
		if($empno!=NULL || $empname!=NULL || $position!=NULL || $salary!=NULL || $aname!=NULL || $address!=NULL || $relation!=NULL || $age!=NULL || $sss!=NULL || $ph!=NULL || $pagibig!=NULL || $tax!=NULL || $total!=NULL || $sss2!=NULL || $ph2!=NULL || $pagibig2!=NULL || $tax2!=NULL || $total2!=NULL || $tded2!=NULL || $tsal2!=NULL || $allotment!=NULL)
					
								if(!mysql_query($query, $db))
								{
									die('Error: ' . mysql_error());
								}
								header('Location: index.php');
					
							mysql_close($db);

?>

I'm confused to what you actually want to do here..

Do you want to display a record inside a text box, so like have an input box and its value is from the table?

OR display a record from the table onto a page?

To me, your code suggests that you're passing data from a form, selecting every record from the table, checking to see if the query executes..

I want to display a record inside a textbox, like what you said, and input box

Right, well, you can't SELECT everything and expect EVERYTHING to display in a text box (Well, you can, but it's not practical lol):

<?php
	$id = (int) 1;
	
	$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
	@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
	$query="SELECT * FROM `profiles` WHERE profile_id='$id'";
	$result = mysql_query($query);
	
	if(mysql_affected_rows() >= 1)
	{
		echo '<form method="post" action="">';
		while($row = mysql_fetch_array($result))
		{
			echo '<input type="text" name="field" value="' .$row['name']. '">';
		}
		echo '</form>';
	}else{
		
	  echo 'There are no records to fetch';
	}
?>

This example selects everything from the table profile, where the profile_id is 1 and if there is a record, displays a text box that has the value of the name.. For example "Phillip"

Hope this helps :)

It doesn't work :(

What error does it give?

It was just an example since I don't have access to your database, I cannot tell what fields you have.. =) Maybe provide some extra details?

<?php

$empno = $_POST['txtempno']; 
$empname = $_POST['txtename'];
$position = $_POST['txtpos']; 
$salary = $_POST['txtsal']; 
$aname=$_POST['txtaname'];
$address=$_POST['txtadd'];
$relation=$_POST['txtremp'];
$age=$_POST['txtage'];
$sss=$_POST['txtsss'];
$ph=$_POST['txtph'];
$pagibig=$_POST['txtpagibig'];
$tax=$_POST['txttax'];
$total=$_POST['txttotal'];
$sss2=$_POST['txtsss2'];
$ph2=$_POST['txtph2'];
$pagibig2=$_POST['txtpagibig2'];
$tax2=$_POST['txttax2'];
$total2=$_POST['txttotal2'];
$tded=$_POST['txttded'];
$tsal=$_POST['txttsal'];
$allotment=$_POST['txtallotment']; 

		$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
		@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
		$query="SELECT * FROM `profiles`";
		
		if($empno!=NULL || $empname!=NULL || $position!=NULL || $salary!=NULL || $aname!=NULL || $address!=NULL || $relation!=NULL || $age!=NULL || $sss!=NULL || $ph!=NULL || $pagibig!=NULL || $tax!=NULL || $total!=NULL || $sss2!=NULL || $ph2!=NULL || $pagibig2!=NULL || $tax2!=NULL || $total2!=NULL || $tded2!=NULL || $tsal2!=NULL || $allotment!=NULL)
					
								if(!mysql_query($query, $db))
								{
									die('Error: ' . mysql_error());
								}
								header('Location: index.php');
					
							mysql_close($db);

?>

these are only my codes.. details?

-stares blankly- :P

Ok, ok

I'm guessing this is one of your field names "empno"?

So you could correct the code like this:

<?php
	$id = (int) 1;
	
	$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
	@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
	$query="SELECT * FROM `profiles` WHERE empno='$id'";
	$result = mysql_query($query);
	
	if(mysql_affected_rows() >= 1)
	{
		echo '<form method="post" action="">';
		while($row = mysql_fetch_array($result))
		{
			echo '<input type="text" name="field" value="' .$row['empname']. '">';
		}
		echo '</form>';
	}else{
		
	  echo 'There are no records to fetch';
	}
?>

I asked for your field names, not your code.. You need to be more descriptive with your problem, otherwise it's hard to help you.

These are my field names,

employeeno
employeename
position
salary
allotteename
address
relation
age

<?php
	$id = (int) 1;
	
	$db=mysql_connect('localhost','root','') or die ('Cannot connect to MYSQL!');
	@mysql_select_db('dbriomra') or die('Cannot connect to database');
		
	$query="SELECT * FROM `profiles` WHERE txtempno='$id'";
	$result = mysql_query($query);
	
	if(mysql_affected_rows() >= 1)
	{
		echo '<form method="post" action="">';
		while($row = mysql_fetch_array($result))
		{
			echo '<input type="text" name="field" value="' .$row['txtename']. '">';
		}
		echo '</form>';
	}else{
		
	  echo 'There are no records to fetch';
	}
?>

Should return a value =) I don't know why you're posting stuff if you want to display something in a text box.. e.g:

<?php

$empno = $_POST['txtempno']; 
$empname = $_POST['txtename'];
$position = $_POST['txtpos']; 
$salary = $_POST['txtsal']; 
$aname=$_POST['txtaname'];
$address=$_POST['txtadd'];
$relation=$_POST['txtremp'];
$age=$_POST['txtage'];
$sss=$_POST['txtsss'];
$ph=$_POST['txtph'];
$pagibig=$_POST['txtpagibig'];
$tax=$_POST['txttax'];
$total=$_POST['txttotal'];
$sss2=$_POST['txtsss2'];
$ph2=$_POST['txtph2'];
$pagibig2=$_POST['txtpagibig2'];
$tax2=$_POST['txttax2'];
$total2=$_POST['txttotal2'];
$tded=$_POST['txttded'];
$tsal=$_POST['txttsal'];
$allotment=$_POST['txtallotment'];

phorce, it's working, Thank you :)

No problem :) Please mark this thread as solved and give rep points to those who have helped you (Click on the arrow buttons by their name) - Best of luck :)

commented: good +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.