mattennant
Members-
Posts
42 -
Joined
-
Last visited
Never
Contact Methods
-
Website URL
http://www.matthewtennant.com
Profile Information
-
Gender
Not Telling
mattennant's Achievements
Member (2/5)
0
Reputation
-
how to insert link inside a html message using mail()
mattennant replied to ok's topic in PHP Coding Help
does this help //send an email here? $body = "Hi\n email body here\n .\n website: http://www.site.com.com Username: {$_POST['username']}\n Password: {$_POST['password']}\n "; mail($_POST['email'], 'subject line here' , $body, 'From: youremail@domain.com'); -
hello have followed darkwaters advice and now have three tables articles - contains article_id - headline- description etc keywords - keyword_id - backpain - fitness training etc keyword_rank keywordrank_id - keyword_id - article_id - rank everytime a new article is added the user s/he checks a checkbox if that keyword is relevent eg []backpain []fitness training etc etc these checked items are stored as rank in the keyword_rank (at the moment as a 1) by query is how best to get the related article to run alongside the article at the moment i have the following (keyword_id 4 is fitness training) SELECT * FROM keyword_rank LEFT JOIN articles ON articles.article_id = keyword_rank. article_id WHERE keyword_id = 4 ORDER by keyword_rank.rank DESC this is fine to relate one keyword, but when two or more are checked i run into problems, i've thought about putting the statement in a loop corresponding to the number of keywords selected, but this would result in the same row getting selected more than once, thinking that there must be a much slicker solution,
-
Thanks darkwater, thought that might well be the case. Is there though a solution to solve this problem, in a kinda unproper manner,before i head down the normalised route, or am i just making more work for myself?? thaks for your time Mat
-
Hi There I'm trying for the first time to relate articles across a site i am building the idea is that everytime say for example a news item is added in the cms, the admin will check 'check boxes' of the categories that story falls into [] backpain [] fitness training [] alternative therapy etc etc at the moment i am storing the array as a comma seperated array in a column called keywords (i realise there could be issues here) so far all well and good i retrieve the data as fllows do { $nkw = explode(',',$row_news['keywords']); if (($row_news['article_id']) ==(in_array($row_article['keywords'], $nkw))){ echo '<li><a href="mat_news.php?article_id=' . $row_news['article_id'] . '" target="_self" title="'.$row_news['headline'] .'">' . $row_news['headline'] . '</a></li>'; } } while ($row_news = mysql_fetch_assoc($news2)); this works fine if there is an exact match from the checked checkboxes, but i want to relate the articles even if there is just a single match from one of the checkboxes, i'm sure this must be simple, but i've been toying with this for ages any help much appreciated mat
-
bingo that's the devil thanks a bunch for your help mat
-
I'm trying to sort out sending an email to admin when a user updates their info all is going fine with the following if ($_POST['mailer'] =='y'){ $body = 'you have a new message from a user.' ; mail($_POST['email'], 'Message from user' , $body, 'blah@blah.com'); but if i try if ($_POST['mailer'] =='y'){ $body = 'you have a new message from a user.' ; $from = 'blah@blah.com' ; mail($_POST['email'], 'Message from user' , $body, $from); i receive the mail, but it comes from Apache rather than blah@blah.com do i need to looka t my server setting, or am i making some stupid error Thanks Mat
-
that worked a treat, thanks so much
-
Hi there I'm trying to display the results of a user table (userdetails) who have not been assigned a particular task in a task table (display_tasks) and to be honest i'm struggling a bit. i can select the users from the task table who have been assigned the task like this a) SELECT FROM userdetails LEFT JOIN display_tasks ON display_tasks.user_id = userdetails.number WHERE display_tasks.task_ref = '170' //170 is the task reference i will get this in from the url but if i try and select the opposite i get all the users who have been assigned other tasks b) SELECT FROM userdetails LEFT JOIN display_tasks ON display_tasks.user_id = userdetails.number WHERE display_tasks.task_ref != '170' //170 is the task reference i will get this in from the url Is there a simple way to do this, put simply terms i want to select all the users from the user table unless they have already been assigned that particular task. Thanks
-
not sure but is it the spelling of contact if (!isset ($_POST['cantactform'])){
-
Hi There I want to insert data from one form into two different tables with one form submit, i want the primary key from 'question' table (main_id) to be the foreign key in the 'question_intro' Is there a way to do this? The only way can think is to get the latest primary key from the 'question' table in a hidden field add 1 to it and insert that number as the foreign key, but that all feels a bit clumsy. here's my code // this tables auto incrementing primary key is called main_id if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO question (task_ref, step_ref, step_type) VALUES (%s, %s, %s)", GetSQLValueString($_POST['task_ref'], "int"), GetSQLValueString($_POST['step_ref'], "int"), GetSQLValueString($_POST['step_type'], "int")); mysql_select_db($database_mattyboy, $mattyboy); $Result1 = mysql_query($insertSQL, $mattyboy) or die(mysql_error()); // iwant to pass the primary key from the above table to this table as the foreign key $insertSQL2 = sprintf("INSERT INTO question_intro (main_id, task_ref, question) VALUES (%s, %s, %s)", GetSQLValueString($_POST['main_id'], "int"),// maybe get this from a hidden field GetSQLValueString($_POST['task_ref'], "int"), GetSQLValueString($_POST['question'], "text")); mysql_select_db($database_mattyboy, $mattyboy); $Result2 = mysql_query($insertSQL2, $mattyboy) or die(mysql_error()); Thanks
-
does this look right to you, getting a mysql error select question_text.question1, answer_text.answer1 from question_text left joint answer_text.foreign on question_text question_text.number=answer_text.foreign FROM question_text WHERE task_ref = 'colname' AND step_ref = 'colname2'
-
i'm just looking into that join query now, thanks for that, will hopefully get this sorted before my eyelids finally shut, thanks for the advice
-
i do have a question id it's called, step_ref, i think i missed that bit out -oops ,i'm having no trouble matching up the q and a's just spitting out all the answers - could be a late night!
-
the query is a bit embarrassing, it's spewed out from dreamweaver, but here goes, here's the answer query $colname2_task_answer = "-1"; if (isset($_GET['step_ref'])) { $colname2_task_answer = (get_magic_quotes_gpc()) ? $_GET['step_ref'] : addslashes($_GET['step_ref']); } $colname_task_answer = "-1"; if (isset($_GET['task_ref'])) { $colname_task_answer = (get_magic_quotes_gpc()) ? $_GET['task_ref'] : addslashes($_GET['task_ref']); } mysql_select_db($database_mattyboy, $mattyboy); $query_task_answer = sprintf("SELECT * FROM answer_text WHERE task_ref = %s AND step_ref = %s", $colname_task_answer,$colname2_task_answer); $task_answer = mysql_query($query_task_answer, $mattyboy) or die(mysql_error()); $row_task_answer = mysql_fetch_assoc($task_answer); $totalRows_task_answer = mysql_num_rows($task_answer); and here's the here's the question query $colname2_task_question = "-1"; if (isset($_GET['step_ref'])) { $colname2_task_question = (get_magic_quotes_gpc()) ? $_GET['step_ref'] : addslashes($_GET['step_ref']); } $colname_task_question = "-1"; if (isset($_GET['task_ref'])) { $colname_task_question = (get_magic_quotes_gpc()) ? $_GET['task_ref'] : addslashes($_GET['task_ref']); } mysql_select_db($database_mattyboy, $mattyboy); $query_task_question = sprintf("SELECT * FROM question_text WHERE task_ref = '%s' AND step_ref = '%s'", $colname_task_question,$colname2_task_question); $task_question = mysql_query($query_task_question, $mattyboy) or die(mysql_error()); $row_task_question = mysql_fetch_assoc($task_question); $totalRows_task_question = mysql_num_rows($task_question); I Know