开发者

How to display all images when a link is clicked by using JQuery, PHP & MySQL?

I have this script that displays ten images or less by default b开发者_StackOverflowut when a user clicks the <a> tag link it displays all the users images.

Is there a way I can display all the users images by having them slide down when a user clicks on the link <a> link instead of refreshing the page using JQuery or PHP?

Here is the php code.

if(isset($_GET['view']) && strlen($_GET['view']) == 1) {
    $view = htmlentities(strip_tags($_GET['view']));
}

$multiple = FALSE;
$row_count = 0;
if(isset($view) == a) {
    $dbc = mysqli_query($mysqli,"SELECT *
                                 FROM images
                                 WHERE images.user_id = '$user_id'");
} else {
    $dbc = mysqli_query($mysqli,"SELECT *
                                 FROM images
                                 WHERE images.user_id = '$user_id'
                                 LIMIT 0, 10");
}
if (!$dbc) {
    print mysqli_error($mysqli);
} else {
    while($row = mysqli_fetch_array($dbc)){ 

    if(($row_count % 5) == 0){
        echo '<ul>';
    }
        echo '<li><img src="/images/thumbs/' . $row['avatar'] . '" /></li>';

if(($row_count % 5) == 4) {
    $multiple = TRUE;
    echo "</ul>";
} else {
    $multiple = FALSE;
}
$row_count++;
}
if($multiple == FALSE) {
    echo "</ul>";
}
}
echo '<a href="../profile/index.php?id=' . $user_id . '&view=a">View All</a>';


Have a look at jquery's load

http://api.jquery.com/load/

Update: if you see in the examples provided you can use:

$('#result').load('ajax/test.html');

where you substitute #result with the id of the element (a <div> for example) where you want put your images

and the 'ajax/test.html' where you put the url of the php code that creates the image list

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜