Hello everyone,
I'm new to PHP, I have been slightly modding it for a while now but never outright writing it until now. I'm trying to write a mod for phpBB and I have it working... somewhat. What I'm wanting to do is read from the database of a gallery script called Coppermine, to tell if a user has uploaded photos, and if they have, show a button for their gallery. All I have it doing is showing the button for everyone so I know my php check via the database is wrong somewhere. Here's what I have:
$user_gallery = 10000+$poster_id;
$result = $db->sql_query("SELECT COUNT(user_id) FROM cpg131_pictures WHERE user_id = ' . $poster_id . '");
$gal_img = '<a href="../gallery/index.php?cat=' . $user_gallery . '"><img src="templates/Crossplay/images/lang_english/icon_gallery.gif" border="0" alt="User photo gallery" title="' . $result . ' Gallery"></a>';
$gal = '';
if ($result[0] != "") {
$ugall_result = $db->sql_query("SELECT p.pid FROM ".$result[0]."pictures AS p, ".$result[0]."albums AS a WHERE a.aid = p.aid AND a.category = $user_gallery");
if ($db->sql_numrows($ugall_result)>0){
$gal_img = '<a href="../gallery/index.php?cat=' . $user_gallery . '"><img src="modules/Forums/templates/subSilver/images/lang_english/icon_gallery.gif" border="0" alt="User photo gallery" title="gallery"></a>';
$gal = '<a href="../gallery/index.php?cat=' . $user_gallery . '">Gallery</a>';
}
}
}
I've integrated phpBB and Coppermine, so Coppermine (or CPG) is using the user table of phpBB. So they're the user number + 10000. For example I'm #2, so my user id would be 10002. In the above code I rigged it to at least show the button for everyone until I could get this fixed. the first $gal_img is for when nothing's found I assume. I started with code for a slightly different forum and have been modifying it to fit mine.
Anyway, here's how the database is structured. I asked the people who made CPG how to call up the information, but their answer assumed I knew php and they aren't willing to help me out with understanding the php it seems. They at least pointed me to the right spot in the phpbb database (which CPG and phpBB now share from integration), I was told to call the cpg131_pictures/owner_id/ inside it, where for each picture it lists the number of the user who uploaded it. Like for me it would list a 2. But I only need to look for one instance of my number 2 in the lines inside the database to return a true or false for my script to display the button.
I'm sure my php for calling the database is really wrong, but I don't know what it is since I'm so new. I would greatly appreciate any help given as this is driving me nuts. I hope what I said in this makes sense, if not please just reply with a question and I'll try my best to clear it up.
Thanks in advance!