How to add a word while inserting the values into mysql?
Dear Friends,
I have a site where I received the keywords with coma separated.
$result=mysql_query("insert into sellingtool (keyword) values ('$keyword);
Suppose I am inserting these keywords.
Juice, Orange Juice, Apple Juice.
And I want this result in data base.
Juice exporter, Orange Juice exporter, Appli Juice exporter.
Please help me our. Awaiting for your expert replies.
Reply from an expert but I am still unable to integrate successfully. Please help me.
$csvstr = "$keyword";
$csv = explode($csvstr, ",");
foreach($csv as $item)
{
$newcsv[] = $item + ' exporter';
}
$newkeyword = implode(", ", $newcsv);
$result=mysql_query("insert into sellingtool (keyword) values ('$newkeyword')");
Source(s):
Experience
Here is my original script:
<?php
session_start();
include("connection.php");
$memberid=$_SESSION['userid'];
$product=$_POST['productname'];
$keyword=$_POST['keyword'];
$cid=$_POST['category'];
$subcatid=$_POST['subcat'];
$subsubcat = $_POST['subsubcat'];
$short_description=$_POST['short_description'];
$long_description=$_POST['long_description'];
$price1=$_POST['price1'];
$price2=$_POST['price2'];
$currency=$_POST['currency'];
$pay1=$_POST['p1'];
$pay2=$_POST['p2'];
$pay3=$_POST['p3'];
$pay4=$_POST['p4'];
$pay5=$_POST['p5'];
$pay6=$_POST['p6'];
$pothers=$_POST['pothers'];
$qty=$_POST['qty'];
$qtype=$_POST['type'];
$qothers=$_POST['qothers'];
$path = $_FILES['file']['tmp_name'];
$file=$_FILES['file']['name'];
$tmpname= explode(".",$file);
$file= $tmpname[0];
if (! is_dir("smallimages/")){
mkdir ("smallimages/", 0777);
}
$path1= "smallimages/";
if (! is_dir("largeimages/")){
mkdir ("largeimages/", 0777);
}
$path2= "largeimages/";
if(isset($_FILES["file"]))
{
if(is_uploaded_file($path))
{
$im = @imagecreatefromjpeg($path);
$width = imagesx($im);
$height = imagesy($im);
$new_small_width=100;
$new_small_height=100;
$image_resized = imagecreatetruecolor($new_small_width, $new_small_height);
imagecopyresampled($image_resized, $im, 0, 0, 0, 0, $new_small_width, $new_small_height, $width, $height);
$random= rand(1,999);
$new_small_jpeg=$file.$random.".jpg";
imagejpeg($image_resized,$path1.$new_small_jpeg);
if (($width>'300') or ($height>'300'))
{
$new_large_width=300;
$new_large_height=300;
$image_resized = imagecreatetruecolor($new_large_width, $new_large_height);
imagecopyresampled($image_resized, $im, 0, 0, 0, 0, $new_large_width, $new_large_height, $width, $height);
$random= rand(1,999);
$new_large_jpeg=$file.$random.".jpg";
imagejpeg($image_resized,$path2.$new_large_jpeg);
}
else
{
$random= rand(1,999);
$new_large_jpeg=$file.$random.".jpg";
imagejpeg($im,$path2.$new_large_jpeg);
}
//echo "<img src=smallimages/".$new_small_jpeg.">";
//echo "<img src=largeimages/".$new_large_jpeg.">";
//exit();
$csvstr = "$keyword";
$csv = explode($csvstr, ",");
foreach($csv as $item)
{
$newcsv[] = $item + ' exporter';
}
$newkeyword = implode(", ", $newcsv);
$result=mysql_query("insert into sellingtool (product,briefdescr,detaildescr,keyword,cid,scid,subcid,price1,price2,currency,pay1,pay2,pay3,pay4,pay5,pay6,pothers,qty,type,qothers,smallimage,largeimage,memberid,date,status) values ('$product','$short_description','$long_description','$newkeyword','$cid','$subcatid','$subsubcat','$price1','$price2','$currency','$pay1','$pay2','$pay3','$pay4','$pay5','$pay6','$pothers','$qty','$qtype','$qothers','$new_small_jpeg','$new_large_jpeg','$memberid',CURDATE(),1)",$link);
}
else
{
$result=mysql_query("insert into sellingtool (product,briefdescr,detaildescr,keyword,cid,scid,subcid,price1,price2,currency,pay1,pay2,pay3,pay4,pay5,pay6,pothers,qty,type,qothers,memberid,date,status) values ('$product','$short_description','$long_description','$newkeyword','$cid','$subcatid','$subsubcat','$price1','$price2','$currency','$pay1','$pay2','$pay3','$pay4','$pay5','$pay6','$pothers','$qty','$
Dear Friends,
I have a site where I received the keywords with coma separated.
$result=mysql_query("insert into sellingtool (keyword) values ('$keyword);
Suppose I am inserting these keywords.
Juice, Orange Juice, Apple Juice.
And I want this result in data base.
Juice exporter, Orange Juice exporter, Appli Juice exporter.
Please help me our. Awaiting for your expert replies.
Reply from an expert but I am still unable to integrate successfully. Please help me.
$csvstr = "$keyword";
$csv = explode($csvstr, ",");
foreach($csv as $item)
{
$newcsv[] = $item + ' exporter';
}
$newkeyword = implode(", ", $newcsv);
$result=mysql_query("insert into sellingtool (keyword) values ('$newkeyword')");
Source(s):
Experience
Here is my original script:
<?php
session_start();
include("connection.php");
$memberid=$_SESSION['userid'];
$product=$_POST['productname'];
$keyword=$_POST['keyword'];
$cid=$_POST['category'];
$subcatid=$_POST['subcat'];
$subsubcat = $_POST['subsubcat'];
$short_description=$_POST['short_description'];
$long_description=$_POST['long_description'];
$price1=$_POST['price1'];
$price2=$_POST['price2'];
$currency=$_POST['currency'];
$pay1=$_POST['p1'];
$pay2=$_POST['p2'];
$pay3=$_POST['p3'];
$pay4=$_POST['p4'];
$pay5=$_POST['p5'];
$pay6=$_POST['p6'];
$pothers=$_POST['pothers'];
$qty=$_POST['qty'];
$qtype=$_POST['type'];
$qothers=$_POST['qothers'];
$path = $_FILES['file']['tmp_name'];
$file=$_FILES['file']['name'];
$tmpname= explode(".",$file);
$file= $tmpname[0];
if (! is_dir("smallimages/")){
mkdir ("smallimages/", 0777);
}
$path1= "smallimages/";
if (! is_dir("largeimages/")){
mkdir ("largeimages/", 0777);
}
$path2= "largeimages/";
if(isset($_FILES["file"]))
{
if(is_uploaded_file($path))
{
$im = @imagecreatefromjpeg($path);
$width = imagesx($im);
$height = imagesy($im);
$new_small_width=100;
$new_small_height=100;
$image_resized = imagecreatetruecolor($new_small_width, $new_small_height);
imagecopyresampled($image_resized, $im, 0, 0, 0, 0, $new_small_width, $new_small_height, $width, $height);
$random= rand(1,999);
$new_small_jpeg=$file.$random.".jpg";
imagejpeg($image_resized,$path1.$new_small_jpeg);
if (($width>'300') or ($height>'300'))
{
$new_large_width=300;
$new_large_height=300;
$image_resized = imagecreatetruecolor($new_large_width, $new_large_height);
imagecopyresampled($image_resized, $im, 0, 0, 0, 0, $new_large_width, $new_large_height, $width, $height);
$random= rand(1,999);
$new_large_jpeg=$file.$random.".jpg";
imagejpeg($image_resized,$path2.$new_large_jpeg);
}
else
{
$random= rand(1,999);
$new_large_jpeg=$file.$random.".jpg";
imagejpeg($im,$path2.$new_large_jpeg);
}
//echo "<img src=smallimages/".$new_small_jpeg.">";
//echo "<img src=largeimages/".$new_large_jpeg.">";
//exit();
$csvstr = "$keyword";
$csv = explode($csvstr, ",");
foreach($csv as $item)
{
$newcsv[] = $item + ' exporter';
}
$newkeyword = implode(", ", $newcsv);
$result=mysql_query("insert into sellingtool (product,briefdescr,detaildescr,keyword,cid,scid,subcid,price1,price2,currency,pay1,pay2,pay3,pay4,pay5,pay6,pothers,qty,type,qothers,smallimage,largeimage,memberid,date,status) values ('$product','$short_description','$long_description','$newkeyword','$cid','$subcatid','$subsubcat','$price1','$price2','$currency','$pay1','$pay2','$pay3','$pay4','$pay5','$pay6','$pothers','$qty','$qtype','$qothers','$new_small_jpeg','$new_large_jpeg','$memberid',CURDATE(),1)",$link);
}
else
{
$result=mysql_query("insert into sellingtool (product,briefdescr,detaildescr,keyword,cid,scid,subcid,price1,price2,currency,pay1,pay2,pay3,pay4,pay5,pay6,pothers,qty,type,qothers,memberid,date,status) values ('$product','$short_description','$long_description','$newkeyword','$cid','$subcatid','$subsubcat','$price1','$price2','$currency','$pay1','$pay2','$pay3','$pay4','$pay5','$pay6','$pothers','$qty','$