This is Value.php
<?php
$conn = mysqli_connect("localhost", "root", "", "cars");
$sql="select id,name from authors";
$authors=mysqli_query($conn,$sql);
if(!$authors){
echo "Error retrieving author table";
exit();
}else{
echo "Go On!!"."<br />";
}
echo "<table border=1 >";
while($author=mysqli_fetch_array($authors)){
$authorid=$author['id'];
$authorname=$author['name'];
echo "<tr>";
echo "<th>"."$authorname \n"."</th>".
"<td>"."<a href='addauthors.php?id=$authorid'>Add</a>"."<br />"."</td>".
"<td><a href='editauthors.php?id=$authorid'>Edit</a> \n"."</td>".
"<td>"."<a href='deleteauthors.php?id=$authorid'>Delete</a>"."<br />"."</td>";
echo "</tr>";
}
echo "</table>";
?>
this is edit authors.php
كود<?php
if($submit):
$conn = mysqli_connect("localhost", "root", "", "cars");
mysqli_select_db($conn, 'jokes');
$insertsql=mysqli_query("update authors(name) values('$authorname')");
if($insertsql){
echo"inserted ";
}else{
echo "Not inserted";
}
?>
<a href="<?php echo($php_self); ?>" >add another author</a>
<a href="Value.php">Back to author list</a>
<?php else: ?>
<form action="<?php echo($php_self);?>" method=post >
<input type="text" name="name" value="<?php echo($authorname);?>" >
<input type="hidden" name="id" value="<?php echo($authorid);?>" >
<input type="submit" name="submit" value="submit" >
</form>
<?php endif; ?>
this is deleteauthors.php
كود<?php
$conn = mysqli_connect("localhost", "root", "", "cars");
$sql="select id,name from authors";
$authors=mysqli_query($conn,$sql);
while($author=mysqli_fetch_array($authors)){
$authorid=$author['id'];
$authorname=$author['name'];
}
$ok1=mysqli_query($conn,"delete from jokes where aid=$authorid");
$ok2=mysqli_query($conn, "delete from authors where id=$authorid");
if($ok1 and $ok2){
echo"Author deleted succefully";
}else{
echo "Something wrong";
}
?>
<br />
<a href="Value.php">Back</a>
this is addauthors.php
كود<?php
if($submit):
$conn = mysqli_connect("localhost", "root", "", "cars");
mysqli_select_db($conn, 'jokes');
$insertsql=mysqli_query("insert into authors(name) values('$authorname')");
if($insertsql){
echo"inserted ";
}else{
echo "Not inserted";
}
?>
<a href="<?php echo($php_self); ?>" >add another author</a>
<a href="Value.php">Back to author list</a>
<?php else: ?>
<form action="<?php echo($php_self);?>" method=post >
<input type=text name=name >
<input type=submit name=submit value=submit >
</form>
<?php endif; ?>and i have this :
إقتباسGo On!!
noha Add
mona Add
LEFT TO RIGHT
and when i click add or edit gives me input text and wehn submit nothing happnes
and when i click delete its gives me that
إقتباسSomething wrong
plzzzz help am trying to study php and these problems confuse me
Thnx in advance