**edit, only just noticed this is not the correct script. So I now pasted the script that runs on the EVO site and flawlessly spits out the list of the letter that was choosen. It s almost all "normal" PHP code.
And gives the
no database selected error if i make a letter choice. Guess I ll stick with EVO.
@AMDBuilder, I know EVO (and REVO) are intuitive enough. It s just that the volunteers I found prefer to work with REVO. Also we re planning to rewrite the snippets to integrate in MODx because that will open loads of options that will be very handy. So, smarter (I think) to migrate to REVO first
@BobRay, the above code is the most important bit of the snippet that connects to the db.
It is plane PHP code with a few MODx "fragments" inside.
It calls externall PHP scripts diplaying what you see on the site mentioned above.
Find the complete snippet below, Frank.
<?php
$idcompdetails = 17;
$idcdelete = 74;
$idcompmod = 18;
$idcomp = $_GET['idcomp'];
$compchar = $_GET['compchar'];
if (strlen($compchar) > 0)
{
$select_subset = true;
$letter = strtoupper(substr($compchar,0,1));
if (is_numeric($letter))
$first_is_number = true;
else $first_is_number = false;
}
else $select_subset = false;
//@mysql_query("SET NAMES 'iso-8859-1'");
//@mysql_query('SET COLLATION_CONNECTION=@@collation_database');
//$result = mysql_query($sql) or die('ERROR: '.$query.' '.mysql_error());
$letterlinks = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
/*echo '<a Composer="top"></a>'; */
echo '<a href="index.php?id=2&compchar=0">0-9</a> ';
for ($i = 0; $i < 26; $i++):
echo '<a href="index.php?id=2&compchar='.$letterlinks[$i].'">'.$letterlinks[$i].'</a> ';
endfor;
//echo "
select_subset = " . $select_subset;
if ($select_subset)
{
// 001: Database query
if ($first_is_number)
$query = "select * from quartets WHERE lname >= '0%' and lname <= '9%'";
else $query = "select * from quartets WHERE lname like '".$compchar."%'";
$query .= " order by lname ASC";
//echo "
query = " . $query;
// 002: Execute query
$res = mysql_query($query);
if (!$res)
{
die ('Could not run query: ' . mysql_error());
}
echo "
";
echo " <table border=\"0\" align=\"left\" width=\"680\"valign=\"left\" color=\"#fafafa\" cellpadding=\"10\" cellspacing=\"2\">";
echo " <thead>";
echo " <tr>";
echo " <th scope=\"row\" bgcolor=\"#cccccc\">Last Name</th>";
echo " <th scope=\"row\" bgcolor=\"#cccccc\">First Name</th>";
echo " <th scope=\"row\" bgcolor=\"#cccccc\">Composition</th>";
echo " <th scope=\"row\" bgcolor=\"#cccccc\">Options</th>";
echo " </tr>";
echo " </thead>";
echo " <tbody>";
$i = 0;
while ($row = mysql_fetch_array($res, MYSQL_BOTH))
while ($row = mysql_fetch_array($res, MYSQL_BOTH))
{
$idcomp = $row[0];
$Opus = $row[4];
$lname = $row[8];
$fname = $row[7];
$information = $row[9];
echo " <tr>";
{
echo "
";
if($i%2 == 0)
{
echo "<tr bgcolor='#F4F6FA'>";
$i++;
}
else
{
echo "<tr bgcolor='#E9EDF5'>";
$i++;
}
}
echo " <td >".$lname."</td>";
echo " <td >".$fname."</td>";
echo " <td >".$Opus."</td>";
echo " <td ><a href=\"/index.php?id=".$idcompdetails."&idcomp=".$idcomp."&compchar=".$compchar."\">
<img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/details.png\" class=\"icon\" alt=\"Vieuw $lname 's details\" title=\"Vieuw $name 's details\" style=\"border:0\"></a>";
if ($email ==!'') {
echo "<a href=\"mailto:$email\">
<img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/email.png\" class=\"icon\" alt=\"Email $name\" title=\"Email $name\" style=\"border:0\"></a>";
}
if (isset($_SESSION['webInternalKey'])) { global $modx;
// User logged in so show icon
echo"
<a href=\"/index.php?id=".$idcompmod."&idcomp=".$idcomp."&compchar=".$compchar."\">
<img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/edit.png\" class=\"icon\" alt=\"Edit $name 's details\" title=\"Edit $name 's details\" style=\"border:0\"></a>";}
else {
// user not logged in
}
if (isset($_SESSION['webInternalKey'])) { global $modx;
// User logged in so show icon
echo"
<a href=\"/index.php?id=".$idcdelete."&idcomp=".$idcomp."&compchar=".$compchar."&abbreviation=".$abbreviation."\">
<img src=\"http://www.pianoquartet.nl/assets/snippets/nbscripts/images/delete.png\" class=\"icon\" alt=\"Delete $name\" title=\"Delete $name\" style=\"border:0\"></a></td>";}
else {
// user not logged in
}
echo " </tr>";
echo " </tr>";
}
echo " </tbody></table>";
}
//mysql_close($sqlConn);
?>
MODX Revolution 2.2.0-pl2 (traditional)
[ed. note: franklos last edited this post 12 years ago.]