I have i DB a table named "jobadd". And in this table i have the columns "Kategori" and "Länk"
in "Kategori" i have different add categorys ex, "bygg" and in "Länk" i have links that will direct a user
to a page so that the user can see the details of this add.
And in the table USERS i have the columns "Kategori" and "email" in "Kategory" i have different categorys that a company
picks when registering on the site ex, "Bygg & Anläggning" and in "email" is the email to this company.
Now what i want is to send a mail to the companys that is in the "USERS" / "Bygg & Anläggning" categoty. After checking
in the "jobadd" table if there are some new (24 hrs) adds in the category "bygg" and if there are, then send a mail containing the
link(Länk) to this add.
I'v got this code but it does not work. i only get this in the mail. $subject = "Ny Förfrågan från Jobler.se"; $message = "Ny Förfrågan från Jobler.se"; $message .= "\r\nLänk: ";
This code does not work at all, but mayby it will giv a hint of what i need?
<?php
$databasename='*********'; // Name of the database
$mysqladd='************'; // Address to the MySQL Server
$mysqluser='*********'; // Your MySQL UserName
$mysqlpass='**********'; // Your MySQL Password
//CONNECT TO MYSQL
$link=mysql_connect($mysqladd, $mysqluser, $mysqlpass, true) or die('Could not connect to database: ' . mysql_error());
//CONNECT TO DATABASE
mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error());
$query="SELECT *, DATE_FORMAT(Time_of_Submission, '%Y/%m/%d') FROM jobadd WHERE Kategori='bygg' AND Time_of_Submission BETWEEN SYSDATE() - INTERVAL 4 DAY AND SYSDATE() ORDER BY ID DESC";
$query2="SELECT * FROM USERS WHERE Kategori='Bygg & Anläggning'";
$row = mysql_fetch_array ($query);
$row2 = mysql_fetch_array ($query2);
$adlink = mysql_real_escape_string($Länk);
$to = $row2['email'];
mysql_close($link);
// From email address
$email = "myemail@mail.com";
// To email addresss
$epost = $to;
// The subject
$subject = "Ny Förfrågan från Jobler.se";
// The message
$message = "Ny Förfrågan från Jobler.se";
$message .= "\r\nLänk: ";
$message .= $adlink;
mail($email, $epost, $subject, $message);
echo "Mail skickat!.";
?>

