$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>";
		echo "cannot connect to the database";	

Recommended Answers

All 3 Replies

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

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

Be a part of the DaniWeb community

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