I'm using a "simple" script that I downloaded for an image galery, since it was a free script there is no support and although the script works great I need a simple modification so people can edit the information they provided with the picture they uploaded.
I manage to add to the script and the database a field to identify which user uploaded what, very basic user id.
Now I want to make the title of the picture a link to an another page where I would pull the information from the database and populate a form to be edited, this should not be a problem.
I already made the changes in the script for that although at this point the form hasen't been created yet, everything works fine if I use a hard value in the script but obviously I need this to be a variable which would be the value of the session $_SESSION['USERID'].
I thought this would be a very simple thing to do but my lack of knowledge of function class and OOP in general made it quite a bit harder than expected, some help would be greatly appreciated, attached is the relevant portion of the code.
// returns HTML code with the image /audio gallery in the specified category
public function getGallery($gal='', $category='') {
$galery = ''; // to store the galery to be returned
// if parameters $gal, and $category not specified, gets their data from properties
if($gal == '') $gal = $this->gal;
if($category == '') $category = $this->category;
$rows = $this->selCategory($gal, $category); // get the rows with files in specified $category
$nrows = count($rows);
// if not error, and at least one row, traverse the $rows, and create the HTML code for Galery, else, return error
if($this->eror === false && $nrows > 0) {
for($i=0; $i<$nrows; $i++) {
$url = $gal.'/'.$rows[$i]['category'].'/'.$rows[$i]['file']; // the path to the file
// Sets in $galery the HTML code with data to be returned
// if image gallery, set link to image with thumbail, else, link to audio file
if($gal == $this->gimgs) {
$thumb = preg_replace('/(.*?)\.(gif|jpg|jpe|png)$/i', '${1}_thmb.${2}', $url);
//MY CODE
$userid = "".$_SESSION['USERID'].""; // ASSIGN VALUE TO $userid
if($rows[$i]['userid'] == '$userid'){ // IF I TRY SESSION HERE THE PAGE WON"T EVEN SHOW UP
$galery .= '<div class="gimgs"><a href="http://www.genaide.ca/edit_image_gallery.php?id='.$rows[$i]['id'].'"><b>'.$rows[$i]['title'].'</b></a><br/><a href="'.$url.'" title="'.$rows[$i]['title'].'" target="_blank"><img src="'.$thumb.'" alt="'.$rows[$i]['title'].'" /></a><br/>'.$rows[$i]['descript'].'</div>';
}else{
$galery .= '<div class="gimgs"><b>'.$rows[$i]['title'].'</b><br/><a href="'.$url.'" title="'.$rows[$i]['title'].'" target="_blank"><img src="'.$thumb.'" alt="'.$rows[$i]['title'].'" /></a><br/>'.$rows[$i]['descript'].'</div>';
}
}
else if($gal == $this->gaudio) {
$galery .= '<a href="'.$url.'" title="'.$rows[$i]['title'].'" target="_blank">'.$rows[$i]['title'].'</a> (<i>'.date('j-M-Y, H:i', $rows[$i]['dtreg']).'</i>)<blockquote>'.$rows[$i]['descript'].'</blockquote>';
}
}
}
else $galery = implode('<br/>', $this->eror);
return $galery;
}