I was looking for a php/mysql based link management script (as
my old one was PERL based and becoming too unstable for my
server), when I ran across LinksCaffe. So, I installed it for one of
my sites and - modified much of the code to accomodate my
needs. It works great, for what I need it for on this site.
So, I decide to use this script for my other site - but my needs for
this site are a little more complicated. The Linkscaffe script lets
you add links from the admin panel - it allows you to choose the
category you want your link placed in. The problem I've run
across is that I need to add 1 link to several categories, and
I'm stumped. I'm sure it's simple, and right in front of my face -
but I am used to working in PERL, not PHP - and am totally
frustrated by my inability to figure this out.
I've tried contacting the support contact for this script - and
posting in their support forums, however the script owners
appear to be 'on vacation', the support forums is a virtual ghost
town (for the most part), with the exception of other people
begging for help. I don't want to beg, but I am near desperate
for help on this.
This is the admin part of the script that allows you to add links:
if ($action=="addlink")
{
$sitenames = "admin :: add a resource";
include "$header";
?>
<table width="<? echo "$tablewidth"; ?>" border="<?
echo "$tableborder"; ?>" cellpadding="10" cellspacing="0"
bordercolor="#000000">
<tr>
<td>
<b><? echo "$sitename"; ?> : admin : add a resource</b>
<br><br>
<form action="<?=$PHP_SELF;?>?action=linkadd" method
="POST">
<table>
<tr>
<td valign="top"><b>Category:</b></td>
<td><select name="lcat_id">
<option value="">- - -</option>
<?
$mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass)
or die ("Cannot make the connection");
mysql_select_db($mysql_db, $mysql_mylink)
or die ("Cannot connect to the database");
$rime = mysql_query("SELECT * from category WHERE sub_cat='0' ORDER BY lcat_id")
or die(mysql_error());
while($row = mysql_fetch_array($rime)) {
extract($row);
$id = $row["lcat_id"];
$name = $row["lcat_name"];
$sub_cat = $row["sub_cat"];
print "<option value='$lcat_id'>$name</option>\n";
$rime1 = mysql_query("SELECT * from category WHERE
sub_cat='$lcat_id'")
or die(mysql_error());
while($row = mysql_fetch_array($rime1)) {
extract($row);
$id = $row["lcat_id"];
$sub_cata = $row["sub_cat"];
$namea = $row["lcat_name"];
print "<option value='$lcat_id'>$name / $namea</option>\n";
}
}
?>
</select></td>
</tr>
<tr><td valign="top"><b>Title:</b></td><td><input type="text"
name="link_name" size="35"></td></tr>
<tr><td valign="top"><b>URL:</b></td><td><input type="text"
name="link_url" size="35"></td></tr>
<tr><td valign="top"><b>Description:</b></td><td><textarea
name="link_desc" cols="34" rows="4"></textarea></td></tr>
<tr><td valign="top"><b>ImageTag:</b></td><td><textarea
name="link_keyword" cols="34"
rows="4"></textarea></td></tr>
<tr><td valign="top"><b>Expires:</b></td><td><input
type="text" name="expires" size="35"></td></tr>
<tr><td valign="top"><b>Code:</b></td><td><input
type="text" name="code" size="35"></td></tr>
<tr><td valign="top"><b>Date Added:</b></td><td><input
type="text" name="date" size="35"></td></tr>
<tr><td valign="top"><b>Hits:</b></td><td><input type="text"
name="visit" size="35"></td></tr>
<td></td>
<td>
<input type="hidden" name="link_val" value="yes">
<input type="hidden" name="link_top" value="">
<input type="hidden" name="link_pop" value="">
<input type="hidden" name="link_broken" value="no">
<input type="hidden" name="link_sendemail" value="">
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="add link"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
<?
exit;
}
if ($action=="linkadd")
{
$sitenames = "admin :: add a resource";
include "$header";
?>
<table width="<? echo "$tablewidth"; ?>" border="<?
echo "$tableborder"; ?>" cellpadding="10" cellspacing="0"
bordercolor="#000000">
<tr>
<td>
<b><? echo "$sitename"; ?> : admin : add a resource</b>
<br><br>
<?
$mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass)
or die ("Cannot make the connection");
mysql_select_db($mysql_db, $mysql_mylink)
or die ("Cannot connect to the database");
$linnk=$link_url;
$rime3 = mysql_query("SELECT * from links WHERE link_url
LIKE '$linnk'")
or die(mysql_error());
$num_url = mysql_numrows($rime3);
if ($num_url < 0){
print "The following link has already been submitted to the
directory for inclusion:<br><br>\n";
$rime2 = mysql_query("SELECT * from links WHERE link_url
LIKE '$link_url'")
or die(mysql_error());
while($row = mysql_fetch_array($rime2)) {
extract($row);
print "<a href=\"$link_url\" target=\"_blank\"
class=\"mainCategory\">$link_name</a><br>\n";
print "$link_desc\n";
print "<div>[Added: $date] <a href=\"$PHP_SELF?
action=linkdel&link_id=$link_id\" class=\"details\">Delete</a>? |
<a href=\"$PHP_SELF?action=edit&link_id=$link_id\"
class=\"details\">Edit</a>?<br><br>\n";
}
}
else
{
$rime = mysql_query("SELECT lcat_name from category")
or die(mysql_error());
if (($lcat_id) &&($link_name) && ($link_url) && ($link_desc) &&
($link_keyword) && ($code))
{
$rime1 = "INSERT into links VALUES
'','$lcat_id','$link_name','$link_url',
'$link_desc','$link_keyword','$code',
'yes','$date','','no','','','$expires','$visit')";
$rime=$rime;
$result = mysql_query($rime1);
print "<b>$link_name</b> is now awaiting validation.<br><br>\n";
print "<a href=\"myadmin.php?action=addlink\">Add Another</a>\n?";
}
else
{
print "You did not enter any data! Please go back and try again.<br><br>\n";
print "<a href=\"myadmin.php?action=addlink\">Add Another</a>?\n";
}
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</body>
</html>
<?
exit;
}
Will post user interface code in post below, message length too long...