I want to to insert value into my single column with website URL and upload path. But I’m really don’t doing that. Here I have 2 columns into my table. And I want to insert the website URL and upload path into 2nd column $website_logo
. Need to be output like this: https://website.com/uploads/image.png
below provided my code:
// insert new data to menu table $sitelink = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]"; $sql_query = "INSERT INTO tbl_category (website_link, website_logo) VALUES('$website_link', '$sitelink'/'$website_logo')";
$sitelink
will get the website URL with HTTP. But it’s not working for me. How I can do that?
Advertisement
Answer
Considering ‘tbl_category’ is MySQL table name and $website_logo holds value ‘image.png’:
$sitelink = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]"; $logo = $sitelink . '/uploads/' . $website_logo; $sql_query = "INSERT INTO tbl_category (website_link, website_logo) VALUES('$sitelink', '$logo')";