Check this out, I did a search and nothing came up. I'm learning php as of now, and am putting alot of the knowledge I gained from this forum to good use, so I appreciate that. Now, the next thing I want to work on, is allowing users to comment on entries from other users....I can see this turning into a forum module itself....ok
So, how can I make this happen...here is a sample of code...you may need to sign up to see it...but, anyways. http://www.humorzilla.com/view.php?ItemID=206
Now, I think I can use this page to look for the information to display that. Here is the source code....
<?
require_once("conn.php");
require_once("access.php");
//get the item details
$q1 = "select * from dd_items where ItemID = '$_GET[ItemID]' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
//get the category
$q2 = "select CategoryName from dd_categories where CategoryID = '$a1[ItemCategory]' ";
$r2 = mysql_query($q2) or die(mysql_error());
$a2 = mysql_fetch_array($r2);
$Item_Category = $a2[0];
$ItemID = $a1[ItemID];
if($a1[ItemSubcategory] > '0')
{
//get the subcategory name
$q3 = "select SubcategoryName from dd_subcategories where SubcategoryID = '$a1[ItemSubcategory]' ";
$r3 = mysql_query($q3) or die(mysql_error());
$a3 = mysql_fetch_array($r3);
$Item_Category .= "/$a3[0]";
}
$Item_Contributor = $a1[Contributor];
//get the rating
$q4 = "select count(ItemID) as n, sum(Rating) as r from dd_rating where ItemID = '$a1[ItemID]' ";
$r4 = mysql_query($q4) or die(mysql_error());
$a4 = mysql_fetch_array($r4);
if($a4[n] > '0')
{
$Item_Rating = number_format($a4[r]/$a4[n], 2, ".", "");
}
else
{
$Item_Rating = "0.00";
}
$View_Item .= "<b>$a1[ItemTitle]</b><br>";
$VenInfo = explode("|", $a1[ItemText]);
$View_Item .= nl2br($VenInfo[0])."<br><br>";
if(!empty($a1[ItemImage]))
{
$MySize = getimagesize("items_images/$a1[ItemImage]");
if($MySize[0] > '100')
{
$MyWidth = '100';
}
else
{
$MyWidth = $MySize[0];
}
$View_Item .= "<img src=\"items_images/$a1[ItemImage]\" style=\"float:left\" width=\"$MyWidth\">";
}
$View_Item .= nl2br($VenInfo[1]);
if($_GET[rate_error] == "y")
{
$message = "<b>Sorry, you have already rated this $main_keyword.</b>";
}
elseif($_GET[rate_error] == "n")
{
$message = "<b>Thank you for rating this $main_keyword.</b>";
}
//get the templates
require_once("templates/MainHeader.php");
require_once("templates/MainView.php");
require_once("templates/MainFooter.php");
?>
therefore, I'd have to use also, the new tag, which you can view here...
http://www.humorzilla.com/post.php
which looks like this....
<?
require_once("conn.php");
require_once("access.php");
if(isset($_POST[s10]))
{
$MyTitle = strip_tags($_POST[title1]);
$cats = explode("|", $_POST[cat1]);
$MyCategory = $cats[0];
$MySubcategory = $cats[1];
$MyText = strip_tags($_POST[text1]);
$t = time();
$q1 = "insert into dd_items set
ItemTitle = '$MyTitle',
ItemCategory = '$MyCategory',
ItemSubcategory = '$MySubcategory',
ItemText = '$MyIn|$MyText',
Contributor = '$_SESSION[username]',
DateAdded = '$t' ";
mysql_query($q1) or die(mysql_error());
header("location:YourItems.php");
exit();
}
//create the categories dropdown
$SelectCategory = "<select name=cat1>\n\t<option value=\"\"></option>\n";
$q1 = "select * from dd_categories order by CategoryName";
$r1 = mysql_query($q1) or die(mysql_error());
while($a1 = mysql_fetch_array($r1))
{
$SelectCategory .= "<option value=\"$a1[CategoryID]|0\">$a1[CategoryName]</option>\n";
//get the subcategories
$q2 = "select * from dd_subcategories where CategoryID = '$a1[CategoryID]' order by SubcategoryName ";
$r2 = mysql_query($q2) or die(mysql_error());
if(mysql_num_rows($r2) > '0')
{
while($a2 = mysql_fetch_array($r2))
{
$SelectCategory .= "<option value=\"$a1[CategoryID]|$a2[SubcategoryID]\">$a1[CategoryName] - $a2[SubcategoryName]</option>\n";
}
}
}
$SelectCategory .= "</select>";
//get the templates
require_once("templates/MainHeader.php");
require_once("templates/MainPost.php");
require_once("templates/MainFooter.php");
?>
So, what I'm guessing, is I need to do edit this....
if(isset($_POST[s10]))
{
$MyTitle = strip_tags($_POST[title1]);
$cats = explode("|", $_POST[cat1]);
$MyCategory = $cats[0];
$MySubcategory = $cats[1];
$MyText = strip_tags($_POST[text1]);
$t = time();
$q1 = "insert into dd_items set
ItemTitle = '$MyTitle',
ItemCategory = '$MyCategory',
ItemSubcategory = '$MySubcategory',
ItemText = '$MyIn|$MyText',
Contributor = '$_SESSION[username]',
DateAdded = '$t' ";
mysql_query($q1) or die(mysql_error());
header("location:YourItems.php");
exit();
}
into something like this....
if(isset($_POST[s10]))
{
$MyCommentsTitle = strip_tags($_POST[comtitle1]);
$coms = explode("|", $_POST[com1]);
$MyComments = $coms[0];
$MyComs = strip_tags($_POST[comstext1]);
$t = time();
$q2 = "insert into dd_comments set
ItemTitle = '$MycomTitle',
ItemCategory = '$MyComments',
ItemText = '$MyInC|$MyComs',
Contributor = '$_SESSION[username]',
DateAdded = '$t' ";
mysql_query($q2) or die(mysql_error());
header("location:YourComments.php");
exit();
}
Am I on the right track? I'm new at this, and I don't want to run into anything I can't complete. I learn by doing, so if I'm pointed in the right direction it may be possible for me to get it done.
thanks in advance for any ideas.