Jump to content

[SOLVED] Trying to add View/ Add Comment link under content item


Xyn1407

Recommended Posts

I am trying to add a View Comment and Add Comment link under a picture/ rate type blog that I am helping a friend with and my php skills have taken me as far as I can get (nowhere)

 

I want the links underneath the pictures to go to a leave comment link and a view comment link. There are multiple picture on one page with the next/previous navigation. Everything else works great.

 

For some reason I just get the index.php?i=$image_id which $image_id should be the id of the picture.

 

Any help on this would be appreciated.

 

Thanks.

 

 

Here is the code of the index.php page.

 

<? require ( "header.php" ); ?>


<?php

$config = './admin/config.php';

if( file_exists( $config ) )
{
    if( is_readable( $config ) )
    {
        require( $config );
    }
    else
    {
        die( "Cannot read config file" );
    }
}
else
{
    die( "Cannot find config file" );
}



/////////////////////////////////////////
////// Prevent Injection Attack /////////
/////////////////////////////////////////
if(isset($_GET['pageno']))
{
    if(!is_numeric($_GET['pageno']))
    {
        return 'Error: '.$_GET['pageno'];
        exit();
    }
    $pageno = $_GET['pageno'];
}
else
{
    $pageno=1;
}

/////////////////////////////////////////
/////////// PAGES FUNCTION //////////////
/////////////////////////////////////////

function pages($tablename, $pageno, $perPage, $query)
{
    $output = '';
    $queryCount = 'SELECT count(*) FROM  ds_images ORDER BY image_id';
    $resultCount = mysql_query($queryCount);
    $fetch_row = mysql_fetch_row($resultCount);
    $numrows = $fetch_row[0];
    
    // Get the comments
   //$queryCount = 'SELECT count(*) FROM  ds_comments ORDER BY comment_id'
   


    $allImages = getTemplate( 'allImages' );

    eval( "\$allImages = \"$allImages\";" );

    $user_login = getUserLogin( $user_id, true, ' class="header"' );

    $imageAltText = getImageName( $image_id, true );

    $size = imageSize( $image_id );

    $imageHeightWidth = $size[ 1 ];

    require( "$GLOBALS[LIB_PATH]/include/profileBar.php" );

    

    // if there is no results
    if($numrows == 0)
    {
        return 'Query returned 0 results.';
        exit();
    }

    $lastpage = ceil($numrows/$perPage);
    $pageno = (int)$pageno;
    if($pageno<1)
    {
        $pageno=1;
    }
    elseif($pageno>$lastpage)
    {
        $pageno=$lastpage;
    }

    // ----- PAGE LINKS -----
    if($pageno==1)
    {
        $pages .= 'FIRST | PREVIOUS ';
    }
    else
    {
        $pages .= "<a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> | ";
        $prevpage=$pageno-1;
        $pages .= " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREVIOUS</a> ";
    }
    $pages .= ' ( Page '.$pageno.' of '.$lastpage.' ) ';
    if($pageno==$lastpage)
    {
        $pages .= ' NEXT | LAST ';
    }
    else
    {
        $nextpage = $pageno+1;
        $pages .= " <a href='".$_SERVER['PHP_SELF']."?pageno=$nextpage'>NEXT</a> | ";
        $pages .= " <a href='".$_SERVER['PHP_SELF']."?pageno=$lastpage'>LAST</a>";
    }

    $limit=' LIMIT '.($pageno-1)*$perPage.', '.$perPage;
    $query  = $query.$limit;
    $result = mysql_query($query);
    if(!$result)
    {
        return 'Query failed: '.mysql_error();
    }
    while($row = mysql_fetch_object($result))
    echo "<div align=center>"."<img src=\"image.php?i=$row->image_id\"/>".'<br />
"<div style=width:45%; align=right>"<a align=right href="imageComments.php?i=$image_id">View Commments</a><br /><div style=width:45%; align=right>"<a align=right href="leaveComment.php?i=$image_id">Leave Comment</a><br /><br />'."</div></div></div>"; 


    {
       // $output = 
        //$output .= $row['image_id'].' '.$row['image'].'<br />';
          // $output = 
        //$output .= $row['comment_id'].' '.$row['comment'].'<br />';
    }

    $output .= '<div style="width:100%; text-align:center; font-size:smaller; color:#fff;">'.$pages.'</div>';
    //$output .=     'Total number of products: '.$numrows;
    return $output;
    exit();
}

/////////////////////////////////////////
////////// Set paramenters //////////////
/////////////////////////////////////////
$tablename = 'ds_images';//.// 'ds_comments';
$perPage = 10;
$query  = 'SELECT * FROM ds_images ORDER BY image_id DESC';
//$query  = 'SELECT * FROM ds_comments ORDER BY comment_id DESC';


echo pages($tablename, $pageno, $perPage, $query);
?> 
<?php 

//require( "$GLOBALS[LIB_PATH]/include/profileBar.php" );


//$rateBarColor = $styleArray[ 1 ];

//$rateBar = getTemplate( 'rateBar' );

//eval( "\$rateBar = \"$rateBar\";" );

$commentsCount = getCommentsCount( $image_id );


require( "$GLOBALS[LIB_PATH]/include/lastFew.php" );

$userExtraFields = getExtraFieldsDisplay( $GLOBALS[ 'TB_USERS' ], $image_id );

$imageExtraFields = getExtraFieldsDisplay( $GLOBALS[ 'TB_IMAGES' ], $image_id );

//$index = getTemplate( 'index' );

//eval( "\$index = \"$index\";" );

//$FinalHTML .= $index;


require( "$GLOBALS[LIB_PATH]/include/footer.php" );

echo cleanFinalOutput( $FinalHTML );

?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.