Show URL herf link with the use of id in PHP MySQL - php

I am having a summary page which will show all the customer name which is called readmsg.php and each of the customer has a unique msgid in MySQL database. The other page can view their details which are called readmsgdetail.php.
However, I am having the problem in using the msgid to display only one customer's details. For now, my readmsgdetail.php can show all the details for all customers.
The code for my readmsg.php:
<div class="row">
<?php
$stmt = $DB_con->prepare('SELECT firstname,lastname,phone,enquiry FROM user_message ORDER BY msgid DESC');
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<div class="col-xs-12">
<p><a class="page-header" href="readmsgdetail.php?msgdetail_id=<?php echo $row['msgid']; ?>"><?php echo $lastname . $firstname; ?></a></p>
</div>
<?php
}
} else {
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
</div>
The code for my readmsgdetail.php:
<?php
require_once 'dbconfig.php';
//////------------------------------------------------
session_start();
if (empty($_SESSION) || empty($_SESSION['login_id'])) {
header('location:login.php');
};
echo"Welcome!! " . $_SESSION['login_id'] . " ";
echo 'log out';
//-----------------------------------------------------
if (isset($_REQUEST['msgdetail_id']) && !empty($_REQUEST['msgdetail_id'])) {
$id = $_REQUEST['msgdetail_id'];
} else {
header("Location: readmsg.php");
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<div class="page-header">
<h1 class="h2">User review <a class="btn btn-default" href="readmsg.php"> all reviews </a></h1>
</div>
<?php
$stmt = $DB_con->prepare('SELECT firstname,lastname,phone,enquiry FROM user_message ORDER BY msgid DESC');
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<form method="post" enctype="multipart/form-data" class="form-horizontal">
<table class="table table-bordered table-responsive">
<tr>
<td><label class="control-label">Name.</label></td>
<td><input class="form-control" type="text" name="name" value="<?php echo $lastname . $firstname; ?>" required /></td>
</tr>
<tr>
<td><label class="control-label">Phone </label></td>
<td><input class="form-control" type="text" name="phone" value="<?php echo $phone; ?>" required /></td>
</tr>
<tr>
<td><label class="control-label">Feedback / Enquiry.</label></td>
<td><input class="form-control" type="text" name="comment" value="<?php echo $enquiry; ?>" required /></td>
</tr>
<tr>
<td colspan="2">
<a class="btn btn-default" href="readmsg.php"> <span class="glyphicon glyphicon-backward"></span> back </a>
</td>
</tr>
</table>
</form>
<?php
}
} else {
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
</div>
</body>
</html>
The stucture of MySQL:
The current result for the webpage:
After I change my select statement to
$stmt = $DB_con->prepare("SELECT firstname,lastname,phone,enquiry FROM user_message where msgid = 'msgdetail_id'");
It shows 'no data found'.

The code in readmsg.php should change to :
$stmt = $DB_con->prepare('SELECT msgid, firstname,lastname,phone,enquiry FROM user_message ORDER BY msgid DESC');
The code in readmsgdetail.php should change to:
$stmt = $DB_con->prepare("SELECT firstname,lastname,phone,enquiry FROM user_message where msgid=$id");
This is woking now! Thx for the help from the comments!.

Related

How to allow only session user to modify review php sql?

This is code for user review system, Everything is working fine with this code but i want to allow only those user to modify their reviews who are on session (logged in) so i just want to add if($_SESSION['id']==$row['user_id']) then open modify page or else echo"Access Denied"; i have tried this code but its not fetching session_id & also i am not sure where should i place this code because i will also block edit page please help anyone..i m stucked
edit page is that page where user can add review
modify page is that page where user can update edit already added review
reviews.php
<?php
session_start();
include('server3.php');
include('config.php');
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$record = mysqli_query($db, "SELECT * FROM info WHERE user_id=$id");
if (count($record) == 1 ) {
$nm = mysqli_fetch_array($record);
$name = $nm['name'];
$address = $nm['address'];
$yid= $nm['id'];
}
}
if (isset($_GET['modify'])) {
$update = true;
$id = $_GET['modify'];
$record2 = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
if (count($record2) == 1 ) {
$n = mysqli_fetch_array($record2);
$name = $n['name'];
$address = $n['address'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="somecss.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="NAV/jquery.min.js"></script>
<script src="NAV/bootstrap.min.js"></script>
</head>
<body>
<header id="fixed-header">
<center><img id="logo" src="logo.png" height="82" width="350" style="border-radius:8px; margin-top:-100px;"/></center>
</header>
<nav class="navbar navbar-inverse" style="margin-bottom:0px;" >
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">NearestMentor.Com</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>What's This</li>
<li>How to Use</li>
<li>Contribute & Win</li>
<li>Winner Mentors Leatherboard</li>
<li>Terms</li>
<li>About Us</li>
<li>Donate Us</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<?php
$loggedin = isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true;
if($loggedin) : ?>
<li><span class="glyphicon glyphicon-pencil"> </span>My Q & A</li>
<li><span class="glyphicon glyphicon-user"> </span>Edit Profile</li>
<li><span class="glyphicon glyphicon-log-in"> </span>Logout</li>
<?php else : ?>
<li><span class="glyphicon glyphicon-user"></span> Sign Up</li>
<li><span class="glyphicon glyphicon-log-in"></span> Login</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
<?php if (isset($_SESSION['message'])): ?>
<div class="msg">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif ?>
<?php $results = mysqli_query($db, "SELECT * FROM info WHERE user_id=$id"); ?>
<table>
<thead>
<tr>
<th>Name</th>
<th>Review</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php while ($row = mysqli_fetch_array($results)) { ?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['address']; ?></td>
<td>
<?php
if($row['user_id']==$_SESSION['id'])
{
echo "<a href='review.php?modify=".$row['id'];"class='edit_btn' >Edit</a>";
}
else
{
echo "";
}
?>
</td>
<td>
Delete
</td>
</tr>
<?php } ?>
</table>
<form method="post" action="server3.php" >
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div class="input-group">
<label>USERID</label>
<input type="text" name="user_id" style="width:670px; height:40px;" value=
"<?php echo $id;?>"
</div>
<div class="input-group">
<label>Name</label>
<input type="text" name="name" style="width:670px; height:40px;" value='<?php echo $_SESSION['username'] ?>' readonly="readonly">
</div>
<div class="input-group">
<label>Give Your Review</label>
<input type="text" name="address" style="width:670px;" value="<?php echo $address; ?>">
</div>
<div class="input-group">
<?php if($update=='true')
{
echo '<button class="btn" type="submit" name="update" style="background: #556B2F;" >update</button>';
}
else
{
echo '<button class="btn" type="submit" name="save" >Save</button>';
} ?>
</div>
</form>
</body>
</html>
server3.php
<?php
session_start();
$db = mysqli_connect('localhost', 'root', '', 'mydatabase');
// initialize variables
$name = "";
$address = "";
$id = 0;
$update = false;
if (isset($_POST['save'])) {
$user_id = $_POST['user_id'];
$name = $_POST['name'];
$address = $_POST['address'];
mysqli_query($db, "INSERT INTO info (user_id, name, address) VALUES ('$user_id','$name', '$address')");
$_SESSION['message'] = "Review Saved, Thankyou!";
header('location: review.php?edit='.$user_id);
}
if (isset($_POST['update'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$address = $_POST['address'];
mysqli_query($db, "UPDATE info SET name='$name', address='$address' WHERE id=$id");
$_SESSION['message'] = "Review Updated, Thankyou!";
echo("<script>alert('Review Successfully Updated!')</script>");
echo("<script>window.location = 'index.php';</script>");
}
if (isset($_GET['del'])) {
$id = $_GET['del'];
mysqli_query($db, "DELETE FROM info WHERE id=$id");
$_SESSION['message'] = "Review Deleted, Thankyou!";
echo("<script>alert('Review Successfully Deleted!')</script>");
echo("<script>window.location = 'index.php';</script>");
}
$results = mysqli_query($db, "SELECT * FROM info");
?>
Why not just use an OAuth login like google to create the user and then use that login to authenticate whether the user can edit a review? It makes it easier for users to create an account, which means you are more likely to get those reviews AND you can check if they are actual customers by implementing a system where they can order online and then do a check if they actually buy from you and verify them as a purchaser. Possibly hide reviews that are spam or non-customer reviews.
I was looking at server3.php and you need to do a lot of checks. This code is vulnerable to MySQL Injections and can easily store garbage data into your database server. I recommend using PDO and prepared queries. I also recommend you check for valid email and escape all data input from the user. Right now I hope this is not on a single live website.

data insert into database automatically in php

I have a problem which is the user when write in my comments form is insert successfully but when I refresh the page it will insert the last comments again , I read the solution in this link how to stop data automatically insert into database in php
but does not work for me
this is my codes I would appreciate for your help :)
file viewhospital.php contain include comments.php file
--look at the bottom of the codes--
<?php
include ('header.php');
if(!isset($_GET['hospital_id'])){
echo '<div class="alert alert-danger" role="alert"><b>You should choose hospital before opening this page!</b></div>';
include ('footer.php');
die();
}
include ('setting.php');
$sql = 'select * from hospital where hid = '. $_GET['hospital_id'];
$result = $conn->query($sql) or die(mysql_error($conn));
$hospital = null;
if ($result->num_rows > 0) {
$hospital = $result->fetch_assoc();
} else {
die('Could not find hospital!');
}
$sql = 'select * from doctor where hospital_id = '. $_GET['hospital_id'];
$doctor_result = $conn->query($sql) or die(mysql_error($conn));
$conn->close();
?>
<div class="row">
<div class="col-md-6">
<p class="text-center">
<img src="<?php echo $hospital['image']; ?>" class="img-thumbnail" style="height: 400px;">
</p>
</div>
<div class="col-md-6">
<p class="text-center">
<img class="img-thumbnail" src="https://maps.googleapis.com/maps/api/staticmap?center=<?php echo $hospital['location']; ?>&zoom=13&size=400x400&maptype=roadmap&markers=color:blue%7Clabel:S%7C<?php echo $hospital['location']; ?>&key=AIzaSyD59nHXpZgqZwjJvsAcPe2CYcIEWoaQ9yY" style="height: 400px;">
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h1 class="page-header">
<?php echo $hospital['name']; ?>
</h1>
<p>
<?php echo $hospital['description']; ?>
</p>
<p>
Address: <?php echo $hospital['address']; ?>
</p>
<p>
Phone: <?php echo $hospital['phone']; ?>
</p>
<p>
Go To Hospital
</p>
<p>
Online Appointment
</p>
</div>
</div>
<!--<div class="row">
<div class="col-md-12 text-center">
<div class="btn-group" role="group" aria-label="...">
<a type="button" class="btn btn-info">Edit</a>
<a type="button" class="btn btn-danger">Remove</a>
<a type="button" class="btn btn-primary" href="doctor_form.php?hospital_id=<?php echo $hospital['hid']; ?>">Add Doctor</a>
</div>
</div>
</div>-->
<div class="row">
<div class="col-md-12">
<table class="table table-striped">
<caption>Doctors:</caption>
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Field</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if ($doctor_result->num_rows > 0) {
while($row = $doctor_result->fetch_assoc()) {
?>
<tr>
<th scope="row">
<?php echo $row['did'];?>
</th>
<td>
<?php echo $row['name'];?>
</td>
<td>
<?php echo $row['field'];?>
</td>
<td>View</td>
</tr>
<?php
}
}else{
?>
<tr>
<th scope="row"></th>
<td>No doctors found</td>
<td></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<?php
include ('comments.php');
include ('footer.php');
?>
the comments.php file
<?PHP
# comments PHP code
date_default_timezone_set('Asia/Riyadh');
function setComments (){
if (isset($_POST['submitComments'])){
include('setting.php');
//$uid = $_POST['uid'];
$date = $_POST['date'];
$message = $_POST['message'];
$sql = "INSERT INTO comments ( date, message) VALUE ( '$date', '$message')";
$result = mysqli_query($conn,$sql);
}
}
function getComments (){
if (isset($_POST['submitComments'])){
include('setting.php');
$sql = "SELECT * FROM comments";
$result = mysqli_query($conn,$sql);
while ($row = $result->fetch_assoc()){
echo "<div class='comments-box'>";
echo $row['date']."<br>";
echo nl2br($row['message'])."<br><br>";
echo "</div>";
}
}
}
echo "
<form action='".setComments ()."' method='POST'>
<input type='hidden' name='uid' value=''>
<input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
<textarea name='message' class='form-control' rows='3'></textarea>
<br>
<button type='submit' name='submitComments' class='btn btn-primary'>Comments</button>
</form>
<br><br>
";
getComments ();
?>
When you refresh in the browser, you send the last request again. That request was the POST of the form. So the user (browser) is telling the code to insert another comment.
Generally this is handled by redirecting after posting a form, rather than re-displaying the form again. Move all of your logic for (and only for) inserting the new content to its own PHP file (something like addComment.php) and have the form post to that file. Then in that file ensure that there is no actual output except perhaps to display an error message if something goes wrong?) and just a redirect back to the page:
header("Location: viewhospital.php");
This will instruct the browser in the response to make a new GET request for viewhospital.php. So if the user reloads the browser, all they're doing is repeating that GET request.

how to send data to php file itself via a hyperlink

I am trying to make a shopping cart with php. I wanted to send id to a php code below in the file. I tried to do it with php_self. And I get these errors.
*Undefined index: movie_id in C:\xampp\htdocs\ITA_WEBSITE\shopping_cart.php on line 60
*mysqli_fetch_object() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ITA_WEBSITE\shopping_cart.php on line 61
*Undefined index: cart in C:\xampp\htdocs\ITA_WEBSITE\shopping_cart.php on line 84
Here's the code
<?php
session_start();
include('dbconfig.php');
$result = mysqli_query($con,"SELECT * FROM movie_details");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Movie Store</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<div class="container-fluid" id="maincontent">
<div class="row">
<?php while($product = mysqli_fetch_object($result)) { ?>
<div class="col-md-4 col-xs-12">
<div class="thumbnail customsthumbs">
<img src=<?php echo $product->image_path;?> alt=<?php echo $product->image_path;?>>
<div class="caption">
<h3 class="customh"><?php echo $product->movie_title;?></h3>
<p id="price">Price : $<?php echo $product->price;?></p>
<p style="text-align:center"><a href=<?php $_SERVER['PHP_SELF'].'?movie_id='?><?php echo $product->movie_id?> class="btn btn-primary custombtn" role="button">
<span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span>Add To Cart</a>
</p>
</div>
</div>
</div>
<?php } ?>
</div>
<?php
include('dbconfig.php');
include('movie_products.php');
$result = mysqli_query($con, 'SELECT * FROM movie_details WHERE movie_id = '.$_GET['movie_id']);
$product = mysqli_fetch_object($result);
if(isset($_GET['movie_id'])){
$item = new Item();
$item->movie_id = $product->movie_id;
$item->movie_title = $product->movie_title;
$item->price = $product->price;
$item->quantity = 1;
$_SESSION['shopping_cart'][] = $item;
}
?>
<div class="container-fluid">
<div class="row">
<div id="cart">
<h3 style="text-align: center;font-size: 40px;padding-top: 5px;">Cart</h3>
<div id="display_cart">
<table border="1" id="display_cart_table">
<tr>
<th>Movie Title</th>
<th>Price</th>
<th>Action</th>
</tr>
<?php
$cart = unserialize(serialize($_SESSION['cart']));
for($i=0; $i<count($cart); $i++){
?>
<tr>
<td><?php echo $cart[$i]->movie_title;?></td>
<td><?php echo $cart[$i]->price;?></td>
<td></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
movie_products.php file
<?php
class Item{
var $movie_id;
var $movie_title;
var $price;
var $quantity;
}
?>
Note: I tried to do this by following a tutorial
Need some help !!
Look at the following statement,
<p style="text-align:center"><a href=<?php $_SERVER['PHP_SELF'].'?movie_id='?> ...
^ see here
You forgot to use echo here. It should be,
<p style="text-align:center"><a href=<?php echo $_SERVER['PHP_SELF'].'?movie_id='?>...
Also, wrap your code block inside an if block, like this:
// your code
if(isset($_GET['movie_id'])){
include('dbconfig.php');
include('movie_products.php');
$result = mysqli_query($con, 'SELECT * FROM movie_details WHERE movie_id = '.$_GET['movie_id']);
$product = mysqli_fetch_object($result);
if(isset($_GET['movie_id'])){
$item = new Item();
$item->movie_id = $product->movie_id;
$item->movie_title = $product->movie_title;
$item->price = $product->price;
$item->quantity = 1;
$_SESSION['shopping_cart'][] = $item;
}
?>
<div class="container-fluid">
<div class="row">
<div id="cart">
<h3 style="text-align: center;font-size: 40px;padding-top: 5px;">Cart</h3>
<div id="display_cart">
<table border="1" id="display_cart_table">
<tr>
<th>Movie Title</th>
<th>Price</th>
<th>Action</th>
</tr>
<?php
$cart = unserialize(serialize($_SESSION['cart']));
for($i=0; $i<count($cart); $i++){
?>
<tr>
<td><?php echo $cart[$i]->movie_title;?></td>
<td><?php echo $cart[$i]->price;?></td>
<td></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
<?php
}

export a csv file from the mysql database

The following code is to import a csv file into database.
<?php
include("includes/config.php");
if ($_POST['frmSubmit']) {
$file = $_FILES['frmUpload']['tmp_name']; // Get Temporary filename
if ($file) {
$handle = fopen($file,"r"); // Open the file and read
while ($strBookData = fgetcsv($handle, 10000, ",")) { // To get Array from CSV
$strDatas[] = $strBookData;
$strTableColumn = count($strBookData); // To Get Column count
}
if ($strDatas) {
$strInsertRecords = 0;
$strDuplicationRecords = 0;
$duplicateEmails = array();
$strDup = "";
if ($strTableColumn == 5) {
for($k=1; $k<count($strDatas); $k++) {
$strStatus = doCheckDuplication($strDatas[$k]['2']);
if ($strStatus==0) {
// Insert Code
doInsertEmployeeDetails($strDatas[$k]['0'], $strDatas[$k]['1'], $strDatas[$k]['2'], $strDatas[$k]['3'], $strDatas[$k]['4']);
$strInsertRecords++; // To Get Inserted Records Count.
} else {
$strDuplicationRecords++; // To Get Duplication Records Count.
$duplicateEmails[$strDuplicationRecords] = $strDatas[$k]['2'];
$strDup.= $duplicateEmails[$strDuplicationRecords]. "\n";
}
}
//printArray($duplicateEmails);
if (count($strDatas)-1 == $strInsertRecords) {
$strMsg = 'Employee details inserted successfully';
$strClass = 'Succes';
}
if (count($strDatas)-1 != $strInsertRecords) {
$strMsg = 'Employee details inserted successfully, some of names already exists';
$strClass = 'Error';
}
if (count($strDatas)-1 == $strDuplicationRecords) {
$strMsg = 'Employee details are already exists';
$strClass = 'Error';
}
} else {
$strMsg = 'Column mis-match, Please verify the file.';
$strClass = 'Error';
}
}
} else {
$strMsg = 'Please upload the valid file.';
$strClass = 'Error';
}
}
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Employee Details</title>
<link href="css/employee.css" rel="stylesheet" type="text/css"/>
<script src="js/employee.js" type="text/javascript"></script>
</head>
<body>
<form id="frmEmployee" name="frmEmployee" enctype="multipart/form-data" method="post" action="" onsubmit="return validation();">
<div class="all">
<div class="alls">
<div class="main">
<div class="inner">
<div class="top">
<p> </p>
<div class="text" align="center">
<p class="det">EMPLOYEE DETAILS</p>
</div>
<p> </p>
</div>
<p> </p>
<div align="center"><p class="<?php echo $strClass; ?>"><?php echo $strMsg; ?></p></div>
<p> </p>
<div class="ntop">
<div class="nnn">
<div class="name">CSV Upload:</div>
<div class="field">
<label>
<input type="file" name="frmUpload" id="frmUpload" onblur="checkEmpty('frmUpload', 'error_file', 'Please upload your file');"/>
</label>
</div>
<p> </p>
</div>
<div class="span">
<div class="span2"><span id="error_file" class="spans"></span></div>
<p> </p>
</div>
</div>
<p> </p>
<p> </p>
<div class="submit">
<div class="sub">
<div class="but">
<label>
<input type="submit" name="frmSubmit" id="frmSubmit" value="Submit" class="subb" />
</label>
</div>
<div class="but">
<label>
<input type="reset" name="frmReset" id="frmReset" value="Reset" class="subb" />
</label>
</div>
</div>
<p> </p>
</div>
</div>
<p> </p>
<?php if ($_POST['frmSubmit']) { ?>
<div class="info" id="one">
<table width="59%" border="1" bordercolor="#DEDEDE" class="tabb">
<tr>
<td width="72%"><p class="rec">Total Records:</p> </td>
<td width="28%"><p class="rec"><?php echo count($strDatas)-1; ?></p></td>
</tr>
<tr>
<td><p class="rec">Inserted Records:</p></td>
<td><p class="rec"><?php echo $strInsertRecords; ?></p></td>
</tr>
<tr>
<td><p class="rec">Duplicate Records:</p></td>
<td><p class="rec"><?php echo $strDuplicationRecords; ?></p></td>
</tr>
</table>
</div>
<div class="dup">
<div class="duplicate">
<div class="hea">
<p class="rec">Duplicate Records</p>
</div>
<p style="height: 10px;"></p>
<div style="padding-left: 10px;"><?php echo $strDup. "<br>"; ?></div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</form>
</body>
</html>
Now i want to export it from the database. Please help me.
you can download adminer.php from this "http://www.adminer.org/" and that will do that job for you. It has all the option to download database in different formats like XML, CSV and text.

Special configuration on xampp vs xampplite?

I've tried to run a php file on xampp which is installed in Ubuntu and WinXP. Both result in error, but it is success when tried to run on xampplite in WinXP. Any special configuration is need to be set on the full xampp version? The php code is as the following:
<?php
require_once('database.php');
// Get category ID
if(!isset($category_id)) {
$category_id = $_GET['category_id'];
if (!isset($category_id)) {
$category_id = 1;
}
}
// Get name for current category
$query = "SELECT * FROM categories
WHERE categoryID = $category_id";
$category = $db->query($query);
$category = $category->fetch();
$category_name = $category['categoryName'];
// Get all categories
$query = 'SELECT * FROM categories
ORDER BY categoryID';
$categories = $db->query($query);
// Get products for selected category
$query = "SELECT * FROM products
WHERE categoryID = $category_id
ORDER BY productID";
$products = $db->query($query);
?>
<!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">
<!-- the head section -->
<head>
<title>My Guitar Shop</title>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<!-- the body section -->
<body>
<div id="page">
<div id="header">
<h1>Product Manager</h1>
</div>
<div id="main">
<h1>Product List</h1>
<div id="sidebar">
<!-- display a list of categories -->
<h2>Categories</h2>
<ul class="nav">
<?php foreach ($categories as $category) : ?>
<li>
<a href="?category_id=<?php echo $category['categoryID']; ?>">
<?php echo $category['categoryName']; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div id="content">
<!-- display a table of products -->
<h2><?php echo $category_name; ?></h2>
<table>
<tr>
<th>Code</th>
<th>Name</th>
<th class="right">Price</th>
<th> </th>
</tr>
<?php foreach ($products as $product) : ?>
<tr>
<td><?php echo $product['productCode']; ?></td>
<td><?php echo $product['productName']; ?></td>
<td class="right"><?php echo $product['listPrice']; ?></td>
<td><form action="delete_product.php" method="post"
id="delete_product_form">
<input type="hidden" name="product_id"
value="<?php echo $product['productID']; ?>" />
<input type="hidden" name="category_id"
value="<?php echo $product['categoryID']; ?>" />
<input type="submit" value="Delete" />
</form></td>
</tr>
<?php endforeach; ?>
</table>
<p>Add Product</p>
</div>
</div>
<div id="footer">
<p>© <?php echo date("Y"); ?> My Guitar Shop, Inc.</p>
</div>
</div><!-- end page -->
</body>
</html>
The database has been created without any problem. Thanks

Categories