<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The Book Center</title>


                include('header.html');	//shtohet pjesa e kodit qe gjendet ne fajllin header.html
  // ne variablat perkatese ruhen vlerat perkatese qe vijne nga fajlli paraprak

//ne qofte se njera nga kto variabla eshte e shprazet d.m.th. nuk kan ardh vlera nga fajlli paraprak nxiret mesazhi me poshte
if (!$bookid || !$title || !$datereal || !$cost || !$pages || !$genderid || !$pubhouseid)
     echo 'You have not entered all the required details!<br />'
          .'Please <a href=addbook.php>go back</a> and try again.';
  $bookid = doubleval($bookid);	//variabla e mer vleren si double
  $title = addslashes($title)	//variables i shtohen slash simbole ("/") qe mos te kete pengese me vone me querin kur do e shkrujm
  $datereal = addslashes($datereal); //...
  $cost = addslashes($cost);	//...
  $pages = addslashes($pages);	//...
  $genderid = doubleval($genderid);	//...
  $pubhouseid = doubleval($pubhouseid);	//...

@ $db = mysql_connect('localhost', 'root');	//krijohet lidhja me serverin

  if (!$db)	//nese $db variabla eshte null d.m.th nuk eshte lidhur me bazen atehere hyn ne if dhe e paraqet mesazhin me poshte:
     echo 'Error: The database connection fail.  Please try again later!';

mysql_select_db('bookcenter');	//selektohet databaza 'bookcenter'
//ne variablen $query, ruhet nje string vlere qe do te perdoret si query per te futur te dhena ne tabelen book
  $query = "insert into book values 
            ('".$bookid."', '".$title."', '".$datereal."', '".$cost."', '".$pages."', '".$genderid."', '".$pubhouseid."')";
  $result = mysql_query($query);	//ekzekutohet query ne databaze dhe rezultati ruhet ne variablen $result
  if ($result)	//nese eshte ekzekutuar me sukses dhe kemi ndonje vlere ne var &result, atehere...
      echo  mysql_affected_rows().' BOOK was inserted into database.'; //... printojme numrin e reshtave qe jane shtuar (qe zakonisht eshte 1)
 <P><b>Your entry has been added.</b> Would you like to
<a href="addbook.php">add another?</a> Or just <a href="login_admin1.php">go Back!</a></p>


echo "<h1 align=center>The BOOK Collection</h1>";

//make the database connection
@ $db = mysql_connect('localhost', 'root');

  if (!$db)
     echo 'Error: Could not connect to database.  Please try again later.';


//create a query
$sql = "SELECT * FROM book";
$result = mysql_query($sql);

print "<table border = 3 align = center>\n";

//get field names
print "<tr>\n";
while ($field = mysql_fetch_field($result)){
  print "  <th>$field->name</th>\n";
} // end while
print "</tr>\n\n";

//get row data as an associative array
while ($row = mysql_fetch_assoc($result)){
  print "<tr>\n";
  //look at each field
  foreach ($row as $col=>$val){
    print "  <td>$val</td>\n";
  } // end foreach
  print "</tr>\n\n";
}// end while

print "</table>\n";



Edited by gonidelux: n/a

6 Years
Discussion Span
Last Post by gonidelux
This question has already been answered. 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.