0
<?php	
	$conn = mysql_connect("localhost", "root", "dotherz"); //connecting to database
	
	if($conn)	//testing if the connection was stablished
	{
		mysql_select_db("orders", $conn);		//selecting database from your localhost
		$qry = "SELECT * FROM customer WHERE customerId = 1"; //the query to get the first user
		
		$result = mysql_query($qry); //executing the qry and passing its values or result into a variable
		
		echo "<h3>Customer Information</h3>";
		echo '<table>';
		echo '<form name="contact_form" method="post" action="send_email.php">';	
		//mysql_fetch_assoc will pass the result in array format, the fieldname as the index
		//and the values are the data from each fields
		
		while($rows = mysql_fetch_assoc($result))
		{
			echo "<tr>";
			echo '<input type="hidden" value="'.$rows['email'].'" name="email">';
			echo "<td>Username:</td>";
			echo '<td><input type="text" value ="'. $rows['username'].'" name="username" /></td>';
			echo "</tr>";
			echo "<tr>";
			echo "<td>Owner:</td>";
			echo '<td><input type= "text" value="'.$rows['lastname']. ', '.$rows['firstname'].' '. $rows['middlename'] .'" name="fulname" /></td>';
			echo "</tr>";
			echo "<tr>";
			echo "<td>Permission:</td>";
			echo '<td><input type="text" value= "'.$rows['type'].'"  name="permission"/></td>';
			echo "</tr>";
			echo "<tr>";			
			echo "<td>Status: </td>";
			echo '<td><input type= "text" value="'.$rows['status'].'" name="status" /></td>';
			echo "</tr>";
			echo "<tr>";			
			echo "<td></td>";
			echo '<td><input type= "submit" value="send this as email" name="email_send" /></td>';
			echo "</tr>";
		}
		echo "</form>";
		echo "</table>";
	}
	else 
	{
		echo "cannot connect to the database";	
	}
	
?>
3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by diafol
0

on line number nine replace with the following:

$result = mysql_query($qry) or die(mysql_error());

it seems like there is an error in ur mysql_query and no data is being given to the $result variable

0
$qry = "SELECT * FROM customer WHERE customerId = 1"

If your connection is OK, it probably means that the query is wrong - either the tablename or the fieldname.

Check the query in phpmyadmin's sql box.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.