PHP-LINKS is a data-driven application that allows collections of links to be viewed by category or located using a powerful search facility. It requires PHP and MySQL to work. The application can be seen working at www.v-consult.co.uk/links.php
By : martin
PHP-LINKS
The following scripts need to be saved under the respective filenames and placed in a virtual directory on a php/mysql enabled web server:
The scripts can be seen working at www.v-consult.co.uk/links.php
print "<h3>Delete or Edit a URL</h3>\n"; print "<h4>Select Edit to modify the URL, name or description and assign categories</h4>\n"; $sql = "select * from urls order by url"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query");
if ( isset($editurlflag) && $editurlflag == "yes" ) { $sql = "update urls set url='$url' where urlID='$urlID'"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); $sql = "update urls set name='$urlname' where urlID='$urlID'"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); $sql = "update urls set description='$urldescription' where urlID='$urlID'"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); } $editurlflag = "";
# Add a Category
$warning=""; global $addcatflag;
if ( isset($addcatflag) && $addcatflag == "yes" ) { $sql = "select catID from cats where category='$category'"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); while ( $a_row = mysql_fetch_array( $sql_result ) ) { $catID=$a_row[catID]; $sql = "select urlID from link where urlID='$urlID' and catID='$catID'"; $result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); while ( $row = mysql_fetch_array( $result ) ) { $warning="yes"; } } if ( $warning == "yes" ) { print "This category already exists"; } else { $sql = "insert into link(urlID, catID) values($urlID, $catID)"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); } } $addcatflag = "";
# Delete a Category
global $delcatflag;
if ( isset($delcatflag) && $delcatflag == "yes" ) { $sql = "delete from link where catID='$catID' and urlID='$urlID'"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); }
print "<h3>Add a Category - At least one Category must be assigned</h3>\n"; print "<form action='$PHP_SELF'>"; print "<input type='hidden' name='addcatflag' value='yes'>"; print "<input type='hidden' name='url' value='$url'>"; print "<input type='hidden' name='urlID' value='$urlID'>"; print "<select name='category'>"; $sql = "select * from cats order by category"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query 1"); while ( $a_row = mysql_fetch_array( $sql_result ) ) { print "<option>$a_row[category]</option>"; } print "</select>"; print "<input type='submit' value='Add Category'>"; print "</form>";
# Categories for this URL with Delete Option
print "<h3>Display Categories for this URL</h3>\n"; $sql = "select category, link.catID as A from link, cats where link.catID=cats.catID and urlID='$urlID order by category'"; $sql_result = mysql_query($sql, $link) or die("Couldn't execute SQL query"); print "<table>"; while ( $a_row = mysql_fetch_array( $sql_result ) ) { print "<tr>"; print "<td><form action='$PHP_SELF'>$a_row[category]</td>"; print "<input type='hidden' name='urlID' value='$urlID'>"; print "<input type='hidden' name='url' value='$url'>"; print "<input type='hidden' name='delcatflag' value='yes'>"; print "<input type='hidden' name='catID' value='$a_row[A]'>"; print "<td><input type='submit' value='Delete'></td>"; print "</form>"; print "</tr>"; } print "</table>\n"; print "<br>"; ?> </body> </html>
====================================== This is a dump from the MySQL Database ======================================
# MySQL dump 8.8 # # Host: localhost Database: linkdemo #-------------------------------------------------------- # Server version 3.23.22-beta
# # Table structure for table 'cats' #
CREATE TABLE cats ( catID int(11) NOT NULL auto_increment, category varchar(50) DEFAULT '' NOT NULL, PRIMARY KEY (catID) );
# # Table structure for table 'link' #
CREATE TABLE link ( urlID int(11) DEFAULT '0' NOT NULL, catID int(11) DEFAULT '0' NOT NULL );
# # Table structure for table 'urls' #
CREATE TABLE urls ( urlID int(11) NOT NULL auto_increment, url varchar(50) DEFAULT '' NOT NULL, name varchar(50) DEFAULT '' NOT NULL, description text, PRIMARY KEY (urlID) );
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.