With this ability you can write your PHP with MySQL from web without scripting. You don't need do hardcode on drupal's script file.
So this is little example on how to write PHP and MySQL code on drupal. This script will call latest submitted stories that have been publish.
<ul>
<?php
$query = "select nid, title from node where status = 1 order by nid desc limit 10";
$result = mysql_query($query) or die("Query failed");
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$url = "node/".$line['nid'];
echo "<li><a href=\"".url($url)."\" title=\"".$line['title']."\">".$line['title']."</a></li>";
}
?>
</ul>
If you want to test it or create another PHP and MySQL code, make sure that on Input format you've choose PHP Code and remember you should include tags on every PHP and MySQL that you've writen.
Have a nice try!
drupal
No comments:
Post a Comment