<?php
$link = mysql_connect('host', 'user', 'pass') or die('Could not connect: ' . mysql_error());
mysql_select_db('database') or die('Could not select database: ' . mysql_error());
$query = "SELECT CONCAT(t2.stored_questionnaire_ID, t1.questionnaire_name, t2.stored_questionnaire_date) AS Link FROM qst_questionnaires AS t1, qst_stored_questionnaires AS t2, mos_users AS t3 WHERE t1.questionnaire_ID = t2.questionnaire_ID AND t2.user_id = t3.id AND t3.username = 'username' ORDER BY t2.stored_questionnaire_date DESC";
$result = mysql_query($query) or die('Query failed: '.mysql_error());
while ($myrow = mysql_fetch_array($result)) {
echo "<a href=\"http:www.domain.com/index2.php?option=com_feedback&sqid=".$myrow["t2.stored_questionnaire_ID"]."\">".$myrow["t1.questionnaire_name"]."</a>, completed on ".$myrow["t2.stored_questionnaire_date"]."<br /><br />";;
}
echo "end";
mysql_free_result($result);
mysql_close($link);
?>
What I'm getting is just the ", completed on" and "end" with no data. I know the query itself works fine, so I'm guessing it has to do with the echo statement -- the only thing I can think of is that maybe having the "." within the field name is causing a problem?
I was about to give up when it hit me... so I've also changed the query (got rid of the CONCAT for now) - and it's almost working...
...now the first two values are working, so I've got a working url being displayed using the data, but the "stored_questionnaire_date" is coming up blank. Does it have to be treated differently because it's last?
$query = SELECT CONCAT('<a href=http://www.domain.com/index2.php?option=com_feedback&sqid=', t2.stored_questionnaire_ID, '>', t1.questionnaire_name,'</a>', ' completed on ', t2.stored_questionnaire_date) AS Link FROM qst_questionnaires AS t1, qst_stored_questionnaires AS t2, mos_users AS t3 WHERE t1.questionnaire_ID = t2. questionnaire_ID AND t2.user_id = t3.id AND t3.username = 'username' ORDER BY t2.stored_questionnaire_date DESC;
how would I get the result to display all returned rows as a list?
var_dump showed me that the correct data was there, and that "Link" was the correct fieldname, so I changed the echo statement and got the output I was looking for.