alert duplicate records in csv upload - php

my csv upload code is like this want to alert duplicate records which are already exists in database i am getting result with $status variable what should i do to alert every duplicate records what is way to alert every duplicate records
if(isset($_POST["Import"]))
{
$filename=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"] > 0)
{
$row = 1;
if (($handle = fopen("$filename", "r")) !== FALSE)
{
while (($data = fgetcsv($handle)) !== FALSE)
{
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
if($c!="" && $c+1!="" && $c+2!=""){
$a[] = $data[$c];
}
}
}
$total = count($a);
$m=0;
$k = 1;
for ($c=0; $c < $total; $c++)
{
$address[$m][] = $a[$c] ;
$z = $address[$m][0];
$q = $address[$m][1];
$q .= $address[$m][2];
$q .= $address[$m][3];
$q .= $address[$m][4];
$q .= $address[$m][5];
$q .= $address[$m][6];
$q .= $address[$m][7];
$q .= $address[$m][8];
$q .= $address[$m][9];
if($a[$c]=="")
{
if($k!=1)
{
$selectcon = "SELECT user_id FROM contact
WHERE user_id = '".$z."'";
$selectRes = mysql_query($selectcon);
if($rows = mysql_fetch_array($selectRes))
{
$user_id = $rows['user_id'];
if($user_id == $z)
{
$staus = 1;
}
else
{
$staus = 1;
}
}
$insertParty = "INSERT INTO contact(user_id)values('$z')";
$res = mysql_query($insertParty);
$contact_id = mysql_insert_id();
$insertAddress = "INSERT INTO address(contact_id,address)VALUES($contact_id,'$q')";
$insertAddressRes = mysql_query($insertAddress);
if(!$insertAddressRes)
{
echo "<sctipt>";
echo "sweetAlert('oops','Import Data Fail','error')";
echo "</sctipt>";
}
else
{
echo "<script>";
echo "swal('Sucess!', 'File Imported Sucessfully!','success')";
echo "</script>";
}
$m++;
}
$k++;
}
}
fclose($handle);
}
}
}
?>

You need to make a unique row inside database. You can't do it with PHP.
Add all columns to a single UNIQUE index, the you can't insert duplicate rows in that table.

Related

php problems with union select distinct

I submitted these two files:
sample_annotation.txt
sample_synteny.txt
I got on the next page the following error:
304501820180500000018.304501820180500000018<br><br>select distinct org1,org2 from '.304501820180500000018.'_synteny union select distinct org1,org2 from '.304501820180500000018.'_synteny<br><br>
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''.304501820180500000018.'_synteny union select distinct org1,org2 from '.3045018' at line 1
Whole query: select distinct org1,org2 from '.304501820180500000018.'_synteny union select distinct org1,org2 from '.304501820180500000018.'_synteny[]
The mGSV/lib/data.php looks like below and caused the above error:
<?php
include('database.php');
## Get parameters
$org = $_GET['org'];
$data = $_GET['data'];
$session_id = $_GET['session_id'];
$array = array();
if($data == 'annotation') {
$query = "SELECT track_name FROM ".$session_id."_annotation WHERE org_id like '$org' GROUP BY track_name ";
$result = mysql_query($query);
if($result != ''){
while($row = mysql_fetch_assoc($result)){
array_push($array, $row['track_name']);
}
}
//array_push($syn_array, "10_50_20_70");
}
else if ($data == 'synteny') {
$query = "DESC ".$session_id."_synteny";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
if($row['Field'] == 'id'){ continue; }
if($row['Field'] == 'blocks'){ continue; }
if($row['Field'] == 'SYNcolor'){ continue; }
if(! preg_match("/^org[12]+[_]?[start|end]?/", $row['Field'])){
array_push($array, $row['Field']);
}
}
}
else if ($data == 'size'){
echo "$session_id.", $session_id, "<br>";
echo "$org", $org, "<br>";
$query = "select distinct org1,org2 from '.$session_id.'_synteny union select distinct org1,org2 from '.$session_id.'_synteny";
echo $query,"<br>";
$result = mysql_query($query);
echo $results,"<br>";
if ($results) {
while($row = mysql_fetch_assoc($result)){
echo $row['org1'], "<br>";
$q = "select max(output) as max from (select max(greatest(org1_start, org1_end)) as output from ".$session_id."_synteny where org1 like '" . $row['org1'] . "' union select max(greatest(org2_start, org2_end)) as output from ".$session_id."_synteny where org2 like '" . $row['org1'] . "') as t1";
echo $q, "<br>";
$res = mysql_query($q);
if (!$res) {
die('Could not query:' . mysql_error());
}
echo $row['org1'],"<br>";
echo $row['org2'],"<br>";
if (! isset($array[$row['org1']])){
//echo "add<br>";
$array[$row['org1']] = mysql_result($res,0);
}
$q = "select max(output) as max from (select max(greatest(org1_start, org1_end)) as output from ".$session_id."_synteny where org1 like '" . $row['org2'] . "' union select max(greatest(org2_start, org2_end)) as output from ".$session_id."_synteny where org2 like '" . $row['org2'] . "') as t1";
#echo $q, "<br>";
$res = mysql_query($q);
if (!$res) {
die('Could not query:' . mysql_error());
}
if (! isset($array[$row['org2']])){
//echo "add<br>";
$array[$row['org2']] = mysql_result($res,0);
}
}
}
else {
echo 'Invalid query: ' . mysql_error() . "\n";
echo 'Whole query: ' . $query;
}
}
else if ($data == 'order'){
$query = "select distinct org1 from ".$session_id."_synteny union select distinct org2 from ".$session_id."_synteny ";
//echo $query,"<br>";
$result = mysql_query($query);
$default = array();
while($row = mysql_fetch_assoc($result)){
array_push($default, $row['org1']);
}
$array = join('__ORDER__', $default);
}
else if ($data == 'sorder'){
$query = "select distinct org1,org2 from ".$session_id."_synteny union select distinct org1,org2 from ".$session_id."_synteny ";
//echo $query,"<br>";
$result = mysql_query($query);
$default = array();
$assarr = array();
while($row = mysql_fetch_assoc($result)){
if( ! in_array($row['org1'], $default)){
array_push($default, $row['org1']);
$assarr[sizeof($assarr)] = array();
}
if( ! in_array($row['org2'], $default)){
array_push($default, $row['org2']);
$assarr[sizeof($assarr)] = array();
}
$len_query = "select sum(org1_end) - sum(org1_start) + sum(org2_end) - sum(org1_start) as sum from ".$session_id."_synteny where (org1 like '".$row['org1']."' and org2 like '".$row['org2']."') OR (org1 like '".$row['org2']."' and org2 like '".$row['org1']."')";
$q_result = mysql_query($len_query);
$q_row = mysql_fetch_assoc($q_result);
#echo $len_query,"<br>";
#echo $q_row['sum'],"<br>";
$assarr[array_search($row['org1'], $default)][array_search($row['org2'], $default)] = $q_row['sum'];
#$assarr[array_search($row['org1'], $default)][array_search($row['org2'], $default)] = 1;
$assarr[array_search($row['org2'], $default)][array_search($row['org1'], $default)] = $q_row['sum'];
#$assarr[array_search($row['org2'], $default)][array_search($row['org1'], $default)] = 1;
#echo array_search($row['org1'], $default) . "][ ". array_search($row['org2'], $default) . '<br>';
$assarr[array_search($row['org1'], $default)][array_search($row['org1'], $default)] = 0;
#echo array_search($row['org1'], $default) . "][ ". array_search($row['org1'], $default) . '<br>';
$assarr[array_search($row['org2'], $default)][array_search($row['org2'], $default)] = 0;
#echo array_search($row['org2'], $default) . "][ ". array_search($row['org2'], $default) . '<br>';
}
$a = FindOrder($assarr);
$sugg = array();
//echo sizeof($a),'<br>';
foreach($a as $b){
//echo $default[$b],"<br>";
array_push($sugg, $default[$b]);
}
$array = join('__ORDER__', $sugg);
}
function FindOrder($graph){
$r = array();
$last = -1;
while(!isEmpty($graph)){
$start = leastEdges($graph);
$path = longestPath($graph, $start, 0);
$path = completeCycle($graph, $path);
if($path[0] != $last){
array_push($r, $path[0]);
}
for($x = 1; $x < sizeof($path); $x++){
array_push($r, $path[$x]);
}
$last = $path[sizeof($path)-1];
$graph = removePath($graph, $path);
}
return $r;
}
function longestPath($graph, $cur, $len){
$path = array();
array_push($path, $cur);
$longestSubpath = array();
for($x = 0; $x < sizeof($graph); $x++){
if($graph[$cur][$x] != 0){
$subpath = longestPath(removeVertex($graph, $cur), $x, $len + $graph[$cur][$x]);
if(sizeof($subpath) > sizeof($longestSubpath)){
$longestSubpath = $subpath;
}
}
}
foreach($longestSubpath as $x){
array_push($path, $x);
}
return $path;
}
function completeCycle($graph, $path){
$graph = removePath($graph, $path);
$last = $path[sizeof($path)-1];
for($x = 0; $x < sizeof($graph); $x++){
if($graph[$last][$x] != 0){
array_push($path, $x);
return $path;
}
}
return $path;
}
function removePath($graph, $path){
for($x = 0; $x < sizeof($path) - 1; $x++){
$arr = $path[$x]; //***forgot the $ in front of path***
$b = $path[$x+1]; //***forgot the $ in front of path***
$graph[$arr][$b] = 0;
$graph[$b][$arr] = 0;
}
return $graph;
}
function removeVertex($graph, $vtx){
if($vtx < 0 || $vtx >= sizeof($graph)){
return copy($graph);
}
for($x = 0; $x < sizeof($graph); $x++){
$graph[$x][$vtx] = 0;
$graph[$vtx][$x] = 0;
}
return $graph;
}
function numEdges($vtx){
$r = 0;
foreach($vtx as $x){
if($x != 0){
$r++;
}
}
return $r;
}
function leastEdges($graph){
$r = -1;
$min = 2147483647;
for($x = 0; $x < sizeof($graph); $x++){
$e = numEdges($graph[$x]);
if($e != 0 && $e < $min){
$r = $x;
$min = $e;
}
}
return $r;
}
function isEmpty($arr){
$r = true;
foreach($arr as $x){
$r = $r && numEdges($x) == 0;
}
return $r;
}
## Return the JSON object
echo json_encode($array);
?>
I created a docker-compose.yml and the can be run in the following way:
git clone https://github.com/mictadlo/mGSV-docker.git
docker-compose up --build
The service can be accessed via localhost and PhpMyAdmin can be accessed via localhost:8183
What did I miss?
Thank you in advance
Try to run independently both query in your Mysql phpmyadmin
select distinct org1,org2 from '.304342020180200000016.'_synteny
select distinct org1,org2 from '.304342020180200000016.'_synteny
As i see your query seems to be correct since union requires the same numbers of columns and same data type.
And why is your table name in the union query is both the same.

How to count the uploaded data's through .csv in php

I have a php code to upload a .csv file this one is working fine. But what i want is if i upload 10 records in a .csv file means it display how many records i upload and in that how many is correctly and how many's are wrong.
Here is my code :
if (isset($_POST["submitbutton"])) {
if (!empty($_FILES['file']['name'])) {
if (pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION) == 'csv') {
$handle = fopen($_FILES['file']['tmp_name'], "r");
//Grab the header in csv
$headers = fgetcsv($handle, 1000, ",");
$not_valid = [];
$i = 1;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$aValid = false;
$field1 = mysql_real_escape_string($data[0]);
$field2 = mysql_real_escape_string($data[1]);
$field3 = mysql_real_escape_string($data[2]);
$field4 = mysql_real_escape_string($data[3]);
$field5 = mysql_real_escape_string($data[4]);
$field6 = mysql_real_escape_string($data[5]);
$field7 = mysql_real_escape_string($data[6]);
$field8 = mysql_real_escape_string($data[7]);
$field9 = mysql_real_escape_string($data[8]);
$sql2 = "select * from m_tl_mastercourse where LMS_Course_ID='$field9'";
$check1 = mysql_query($sql2);
$sql = "select * from mdl_course where id='".$field9."'";
$check = mysql_query($sql);
$row=mysql_fetch_array($check);
if (mysql_num_rows($check) > 0 && mysql_num_rows($check1) < 1) {
$aValid = true;
} else {
$not_valid[] = $i;
}
if ($aValid) {
echo count($i);
$import = "INSERT into m_tl_mastercourse values('','$field1','$field2','$field3','$field4','$field5','$field6','$field7','$field8','$field9')";
mysql_query($import);
$last_id = mysql_insert_id();
if($last_id){
$sql = "select m_tl_mastercourse.Id, Course_Type from m_tl_mastercourse inner join mdl_course where m_tl_mastercourse.LMS_Course_ID = mdl_course.id ";
$ret = get_records_sql($sql);
foreach ($ret as $index => $obj) {
$master_id = $obj->Id;
$course_type = $obj->Course_Type;
}
echo $master_id;
echo $course_type;
$query = mysql_query("update m_tl_course INNER JOIN m_tl_mastercourse ON m_tl_course.course_id = m_tl_mastercourse.LMS_Course_ID SET m_tl_course.course_type='$course_type',m_tl_course.master_id='$master_id' WHERE m_tl_course.master_id='' ");
}
}
$i++;
}
fclose($handle);
if (!empty($not_valid)) {
$v_ids = implode(', ', $not_valid);
echo count($v_ids);
echo "Please check the following csv Row Number's - " . $v_ids;
} else {
echo "Master Courses Uploaded Successfully";
}
} else {
echo "<script>alert('csv files only allowed to upload')</script>";
}
} else {
echo "<script>alert('Please select a file')</script>";
}
}
?>
How to get like this
The variables are already in your code: $i is incremented on each loop, and $not_valid is an array containing the row numbers for any rows that are evaluated as not valid.
You can use count($not_valid) to get the number.
// $i starts at 1 and is incremented on the completion of each loop so will end 1 more than the total rows
$total_rows = $i - 1;
$valid_rows = $i - 1 - count($not_valid);
$invalid_rows = count($not_valid);

Why Getting only 1 array instead of many arrays?

I am a completely newbie in programming php I would like to make this code below return many arrays(to flash as3), however I only receive one array.Can anyone please pinpoint what is my mistake here? thanks.
$data_array = "";
$i = 0;
//if(isset($_POST['myrequest']) && $_POST['myrequest'] == "get_characters")
//{
$sql = mysqli_query($conn, "SELECT * FROM ns_users ORDER BY Char_id");
while($row = mysqli_fetch_array($sql))
{
$i++;
$fb_name = $row["Username"];
$fb_id = $row["Fb_id"];
$fb_at = $row["Access_token"];
$fb_sig = $row["Fb_sig"];
$char_id = $row["Char_id"];
if($i == 1)
{
$data_array .= "$fb_name|$fb_id|$fb_at|$fb_sig|$char_id";
}
else
{
$data_array .= "(||)$fb_name|$fb_id|$fb_at|$fb_sig|$char_id";
}
echo "returnStr=$data_array";
exit();
}
When you write your exit insight your loop you stop executing your program and you get only one record. You should set the echo and exit after your while loop.
$data_array = "";
$i = 0;
$sql = mysqli_query($conn, "SELECT * FROM ns_users ORDER BY Char_id");
while($row = mysqli_fetch_array($sql)) {
$i++;
$fb_name = $row["Username"];
$fb_id = $row["Fb_id"];
$fb_at = $row["Access_token"];
$fb_sig = $row["Fb_sig"];
$char_id = $row["Char_id"];
if($i == 1) {
$data_array .= "$fb_name|$fb_id|$fb_at|$fb_sig|$char_id";
} else {
$data_array .= "(||)$fb_name|$fb_id|$fb_at|$fb_sig|$char_id";
}
}
echo "returnStr=$data_array";
exit();
Those two last line of your should be outside of your loop:
$data_array = "";
$i = 0;
//if(isset($_POST['myrequest']) && $_POST['myrequest'] == "get_characters")
//{
$sql = mysqli_query($conn, "SELECT * FROM ns_users ORDER BY Char_id");
while($row = mysqli_fetch_array($sql))
{
$i++;
$fb_name = $row["Username"];
$fb_id = $row["Fb_id"];
$fb_at = $row["Access_token"];
$fb_sig = $row["Fb_sig"];
$char_id = $row["Char_id"];
if($i == 1)
{
$data_array .= "$fb_name|$fb_id|$fb_at|$fb_sig|$char_id";
}
else
{
$data_array .= "(||)$fb_name|$fb_id|$fb_at|$fb_sig|$char_id";
}
}
echo "returnStr=$data_array";
exit();
If you would name the columns that you want in the SELECT then it's much simpler. Make sure to use MYSQLI_ASSOC in the fetch:
$sql = mysqli_query($conn, "SELECT Username, Fb_id, Access_token, Fb_sig, Char_id FROM ns_users ORDER BY Char_id");
while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC))
{
$data_array[] = implode('|', $row);
}
echo "returnStr=" . implode('(||)', $data_array);
exit();

Conflict between mysql_fetch_row and mysql_fetch_array

I have a function in PHP that give me some values from DB
$select = mysql_query("SELECT * FROM sfide WHERE accepted = 0");
if($select){
if(mysql_fetch_row($select) != 0){
$sep = "~";
$return = "";
$i = 0;
while($row = mysql_fetch_array($select)){
if($i > 0){
$return = $return.",";
};
$return = $return.$row['id'].$sep.$row['from_'];
$i += 1;
}
return $return;
}else{
return "NO";
}
}else{
return "E, 000, SELECT, ".mysql_error();
}
The problem is that if I do like in the code above it returns me nothing, instead, if I duplicate the select variable it works:
$select = mysql_query("SELECT * FROM sfide WHERE accepted = 0");
$num_select = mysql_query("SELECT * FROM sfide WHERE accepted = 0");
if($select){
if(mysql_fetch_row($num_select) != 0){
$sep = "~";
$return = "";
$i = 0;
while($row = mysql_fetch_array($select)){
if($i > 0){
$return = $return.",";
};
$return = $return.$row['id'].$sep.$row['from_'];
$i += 1;
}
return $return;
}else{
return "NO";
}
}else{
return "E, 000, SELECT, ".mysql_error();
}
Why ?
Instead of
mysql_fetch_row($select) != 0
use
mysql_num_rows($select) != 0
that will return an int for you to compare.

Trouble pulling data out of an sql table

I have a html form tat my user can use to search through a table in my MYSQL database.
By default if you just hit go it will display the entire table, however I would like them to be able select certain fields and my php form to search via the fields that are filled in.
I seem to be unable to find a way of doing this without writing a seperate query for all 11 inputs in the different combinations they could be entered in, which comes out at a total of 76 queries..
If anyone has a way to simplify this I would love any advice.
I have tried just running a query with the AND operator but that doesnt work as some variables can be left empty and that will return no result, not sure if that is what is upposed to happen, but that is what is happening.
my html and php:
http://jsbin.com/oquwid/1/edit
PHP
$sql = "SELECT * FROM ".$tbl_name."
WHERE fname='".$fname."'
and lname='".$lname."'
and city='".$city."'
and phone='".$pohne."'
and interest_inet='".$internet."'
and interest_tv='".$television."'
and interest_voice='".$voice."'
and submission_ip='".$ip."'
and inquiry_handled='".$handled."'";
$result = mysql_query($sql);
echo "<table border='1'>";
echo "<tr>";
$i = 0;
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo "<th>".$meta->name."</th>";
$i++;
}
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
foreach($row as $item)
{
echo "<td>".$item."</td>";
}
echo '</tr>';
echo $row;
}
echo "</table>";
You could append parts to the query depending on which are filled in:
if(!empty($fname) || !empty($lname) || !empty($city) || etc.etc.) {
$sql = "SELECT * FROM $tbl_name WHERE ";
$queryParts = array();
if($fname != "") {
$queryParts[] = " fname='$fname'";
}
if($lname != "") {
$queryParts[] = " lname='$lname'";
}
etc.etc.
$sql .= implode(" AND ", $queryParts);
// do query, etc.
}
else {
// Don't do query if no parameters are specified
}
You also need to make sure that you escape all of your query parameters before you use them or risk having someone ravage your data.
The following uses loops to avoid duplicate code:
$fieldIsSpecified = false;
$queryFields = array('fname' => $fname, 'lname' => $lname, 'city' => $city, etc...);
foreach($queryFields as $column => $value) {
if(!empty($value){
$fieldIsSpecified = true;
break;
}
}
if($fieldIsSpecified) {
$sql = "SELECT * FROM $tbl_name WHERE ";
$queryParts = array();
foreach($queryFields as $column => $value) {
if(!empty($value)) {
$queryParts[] = " $column = '$value'";
}
}
$sql .= implode(" AND ", $queryParts);
// do query, etc.
}
else {
// Don't do query if no parameters are specified
}
The reason you're query isn't working if a value is not filled in, is probably because the query results in this (given first name is empty)
SELECT * FROM $tbl_name WHERE fname=''
And there probably isn't a user having no first name.
Further, you considered adding a flag per requested info, and on base of that either add or remove the needed part to the select part of the query ?
For example,
$sql = "SELECT * FROM $tbl_name WHERE ";
$queryChanged = false;
if (isset($fname)){
if (!empty($fname)){
$sql .= "fname='$fname' ";
$queryChanged=true;
}
}
if (isset($lname)){
if (!empty($lname)){
$sql .= ($queryChanged) ? " AND lname='$lname'" : "lname='$lname'";
$queryChanged = true;
}
}
... //Continue the logic
I'd recommend you to read this post about select * as well as this about user input and how to handle it
this is how i am going to have to do it
php:`
//if just lname is set
if(empty($start_date) && empty($end_date) && empty($fname) && isset($lname) && empty($city) &&
empty($internet) && empty($television) && empty($voice) && empty($phone) && empty($ip) &&
empty($handled) && empty($not_handled)){
$sql = "SELECT * FROM ".$tbl_name."
WHERE lname='".$lname."'";
$result = mysql_query($sql);
echo "<table border='1'>";
echo "<tr>";
$i = 0;
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo "<th>".$meta->name."</th>";
$i++;
}
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
foreach($row as $item)
{
echo "<td>".$item."</td>";
}
echo '</tr>';
}
echo "</table>";
exit();
}
//if just city is selected
if(empty($start_date) && empty($end_date) && empty($fname) && empty($lname) && isset($city) &&
empty($internet) && empty($television) && empty($voice) && empty($phone) && empty($ip) &&
empty($handled) && empty($not_handled)){
$sql = "SELECT * FROM ".$tbl_name."
WHERE city='".$city."'";
$result = mysql_query($sql);
echo "<table border='1'>";
echo "<tr>";
$i = 0;
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo "<th>".$meta->name."</th>";
$i++;
}
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
foreach($row as $item)
{
echo "<td>".$item."</td>";
}
echo '</tr>';
}
echo "</table>";
exit();
}
And etc... i am going to have to repeat this process until i cover all, 76 i believe, possibilites. thnkfully its just a lot of copy paste. thanks for the help everyone
First don't use MYSQL_*. Use PDO
Second, with your code, your are requiring all fields to be filled.
If you don't wanna do that then go this way:
You can use WHERE 1=1 , but it's not recommended !!!!!
$sql = "SELECT * FROM ".$tbl_name." WHERE confirm = '0' ";
$sql .= "AND fname = ".$fname."";
$sql .= "AND lname = ".$lname."";
$sql .= "AND city = ".$city."";
$sql .= "AND phone = ".$pohne."";
$sql .= "ORDER BY date DESC";
$result = mysql_query($sql);
echo "<table border='1'>";
echo "<tr>";
$i = 0;
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo "<th>".$meta->name."</th>";
$i++;
}
while ($row = mysql_fetch_row($result))
{
echo '<tr>';
foreach($row as $item)
{
echo "<td>".$item."</td>";
}
echo '</tr>';
echo $row;
}
echo "</table>";

Categories