Skip to content

Instantly share code, notes, and snippets.

@mazetar
Created November 6, 2013 00:11
Show Gist options
  • Save mazetar/7328661 to your computer and use it in GitHub Desktop.
Save mazetar/7328661 to your computer and use it in GitHub Desktop.
<body>
<h3>Modding resources</h3>
<p>You may filter the list by filling out this form:</p>
<form method="post" action="search.php?go" id="searchform">
Name:
<input type="text" name="Name">
<!-- Keywords:
<input type="text" name="keywords">
<br> -->
Author:
<input type="text" name="Author"><br/>
Type: <br/>
<input type="checkbox" name="Type[]" value="Forge">
Forge
<input type="checkbox" name="Type[]" value="Bukkit">
Bukkit
<input type="checkbox" name="Type[]" value="Other">
Other
<input type="checkbox" name="Type[]" value="General">
None/General <br/>
<input type="submit" name="submit" value="Search">
<br/>
</form>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("minecraft", $con);
$query = "SELECT * FROM `mctuts_tutorials` WHERE 1";
if(isset($_POST['submit']))
{
if(isset($_GET['go']))
{
$name=$_POST['Name'];
$author=$_POST['Author'];
$type=$_POST['Type'];
// NAME & TAGS
// TYPE
if (count($type) > 1)
{
$t1=$type[0];
$typeQuery = "Type='$t1'";
for ($i = 1; $i < count($type); $i++) {
$t = $type[$i];
$typeQuery = $typeQuery . " OR Type=\"$t\"";
}
}
if (count($type) === 1)
{
$typeQuery= "Type='$type[0]'";
$typeQuery = "AND (" . $typeQuery . ");";
}
else if (count($type) < 1)
{
$typeQuery = "";
}
else
{
$typeQuery = "AND (" . $typeQuery . ");";
}
// "AND (" . $typeQuery . ");"
$query="SELECT * FROM mctuts_tutorials WHERE Author LIKE '%" . $author ."%'" .
$typeQuery . $nameQuery;
}
}
else
{
// query is the default one;
$query = "SELECT * FROM `mctuts_tutorials` WHERE 1 ORDER BY Name";
}
// START OF DISPLAY TUTORIALS
//echo "$query";
$tutorials = mysql_query($query);
if (!$tutorials) {
die('Invalid query: ' . mysql_error());
}
echo '<table border="4px" cellpadding="5">';
echo '<tr>'; // start first row
echo "<tr><th>Name</th> <th>Type</th> <th>Author:</th> <th>Description:</th> <th>Version:</th> <th> 1.6 Status:</th> <th>Notes:</th> <th>Tags:</th> </tr> ";
echo '</tr>';
$color_works = "#00FF00";
$color_minor = "#FFCC00";
$color_error = "#FF0000";
$color_untested = "#33CCCC";
$status_works = "Works";
$status_minor = "Minor";
$status_error = "Error";
$status_untested = "Untested";
while($row = mysql_fetch_array($tutorials, MYSQL_BOTH))
{
$users_name = $row['Name'];
$users_type = $row['Type'];
$users_author = $row['Author'];
$users_mcver = $row['MCVersion'];
$users_url = $row['Link'];
$users_desc = $row['Description'];
$users_tags = $row['Tags'];
$users_status = $row['Status'];
$users_note = $row['VersionNotes'];
$type_cell = "<td>$users_type</td>";
$color_current = $color_untested;
//General Other ML Bukkit Forge
if ($users_type == "Forge")
{
$type_cell = "<td><img src=\"logo_forge.png\" /></td> ";
}
elseif ($users_type == "Bukkit")
{
$type_cell = "<td><img src=\"logo_bukkit.png\" /></td> ";
}
echo "<tr><td><a href=$users_url>$users_name</a></td>";
echo "$type_cell <td>$users_author</td> <td>$users_desc</td> <td>$users_mcver</td>";
if ($users_status === $status_works)
{
$color_current = $color_works;
}
elseif ($users_status === $status_minor)
{
$color_current = $color_minor;
}
elseif ($users_status === $status_error)
{
$color_current = $color_error;
}
echo "<td bgcolor=$color_current>$users_status</td> <td>$users_note</td> <td>$users_tags</td> </tr> ";
}
mysql_close($con);
// END OF DISPLAY TUTORIALS
echo "<a href=\"http://www.quick-counter.net/\" title=\"HTML hit counter - Quick-counter.net\"><img src=\"http://www.quick-counter.net/aip.php?tp=di&tz=Europe%2FOslo\" alt=\"HTML hit counter - Quick-counter.net\" border=\"0\" /></a>";
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment