Customizing SMF > SMF Coding Discussion
First time using database entries, need help calling out a row.
Liam_michael:
I'd like to call out the latest entry in the si_page column and its corresponding title (so, according to the picture, I want to call out the word "anastomose". I've done this so far:
--- Code: ---$dbresult = db_query("
SELECT
si_title, si_page
FROM smf1searchindex
WHERE si_title = $deftitle
ORDER BY si_page DESC
LIMIT 1", __FILE__, __LINE__);
$deftitle = mysql_fetch_assoc($dbresult);
// Call out word
echo'',$deftitle,'';
--- End code ---
This is the first time I work with databases and calling out certain objects in tables, so my knowlege is very limited. Could someone point me out on where I've made a mistake?
live627:
list ($si_title, $si_page) = mysql_fetch_row($dbresult);
mysql_free_result($dbresult);
echo $si_title;
Liam_michael:
--- Quote from: live627 on June 28, 2012, 09:37:02 PM ---list ($si_title, $si_page) = mysql_fetch_row($dbresult);
mysql_free_result($dbresult);
echo $si_title;
--- End quote ---
Thanks for the reply, but could you tell me where to put that :-[ Once again, I'm weak when it comes to database entries.
Like this?
--- Code: ---$dbresult = db_query("
SELECT
si_title, si_page
FROM smf1searchindex
WHERE si_title = $deftitle
ORDER BY si_page DESC
LIMIT 1", __FILE__, __LINE__);
list ($si_title, $si_page) = mysql_fetch_row($dbresult);
mysql_free_result($dbresult);
--- End code ---
live627:
You seem to be better than you think ;)
Perfect spot for it!
Liam_michael:
Thanks live627,
I tried this exact thing:
--- Code: ---$dbresult = db_query("
SELECT
si_title, si_page
FROM smf1searchindex
WHERE si_title = $deftitle
ORDER BY si_page DESC
LIMIT 1", __FILE__, __LINE__);
list ($si_title, $si_page) = mysql_fetch_row($dbresult);
mysql_free_result($dbresult);
echo '',$si_title,';
--- End code ---
I didn't get an output, just blank.
I think it has to do with $deftitle
--- Code: ---WHERE si_title = $deftitle
--- End code ---
Should that even be there? I just put that there for fun.
What am I doing wrong still?
Navigation
[0] Message Index
[#] Next page
Go to full version