Php mysql question

So,I created database on phpmyadmin.
then,I used the code to show all the info on my page.It works.
Here is the code:

$servername="localhost";
$username="root";
$password="";
$dbname="xxxxx";

$conn=mysqli_connect($servername,$username,$password,$dbname);
$abc="select*from employee";
$res=mysqli_query($conn,$abc);
while($row=mysqli_fetch_assoc($res)){
	echo 
$row['name']."<br> ".
$row['lname']."<br> ".
$row['occupation']."<br> ".
$row['photo']." <br>";
}

Now,I want to:
1-update the information(let’s say the path of a photo)
2-update the information(one of the employees changed their name)
3-how to connect “search” button on html page and this database?I know it goes trough $_POST,but nothing worked so far.

//if(solution==true)
echo “thank you”;
else
echo “thank you,again”;
:slight_smile:

Well if you have some kind of registration/login system then you can use the id of the person (or even have an administrator) change that for you could use the unique id and security level to update that record.

for example

if ($user['id] === $employee['user_id'] || $user['security_level'] === 'admin' ) {
   /* Edit Record */
}

Show us the code you’ve tried so far.

$query="select*from xxxxx";

if(isset($_POST['search'])) {
	$searchq=$_POST['search'];
	$rez=mysqli_query($conn,$upit) or die("Connection problem No. 3");
	if($count==0){
		$output="No results found";
	}
	else if($row=mysqli_fetch_array($query)) {
		$id=$row["id"];
		$naziv=$row["naziv"];
		$tip=$row["tip"];
		$potpisnik=$row["potpisnik"];
		$output.=$id." ".$naziv." ".$tip." ".$potpisnik;
	}

it reports problem on “connection problem no 3”

I don’t see any code where you open a connection to the database, is that in a separate include file? You also don’t use the value of the $_POST variable in your query. Is it OK to use the query as you type it, without spaces around the *? I wonder if it might have a parse error.

which means that the query failed. which is no wonder with that query …

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.