Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:28:13+00:00 2026-06-09T11:28:13+00:00

Im try make a slider and load data dynamically from a php file, im

  • 0

Im try make a slider and load data dynamically from a php file, im get image from database but i have problem now to link this image…

Here is my php file ajax_php.php

// Array indexes are 0-based, jCarousel positions are 1-based.
$first = max(0, intval($_GET['first']) - 1);
$last  = max($first + 1, intval($_GET['last']) - 1);
$length = $last - $first + 1;
// ---
require_once('../../includes/config.php');
error_reporting(0);
mysql_connect($conf['host'], $conf['user'], $conf['pass']);
mysql_select_db($conf['name']);
$getUser = "SELECT * FROM sitex WHERE img_i!='images/img_i.jpg' ORDER BY `sitex`.`likes` DESC LIMIT 35";
$res = mysql_query($getUser) or die();

$images = array();

while(($row =  mysql_fetch_assoc($res))) {
    $images[] = '/images/'.$row['img_i'].'';
}

$total    = count($images);
$selected = array_slice($images, $first, $length);

// ---

header('Content-Type: text/xml');

echo '<data>';

echo '  <total>' . $total . '</total>';
foreach ($selected as $img) {
    echo '<image>' . $img . '</image>';
} 
echo '</data>';

And here is js

function mycarousel_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
        'ajax_php.php',
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        },
        'xml'
    );
};

function mycarousel_itemAddCallback(carousel, first, last, xml)
{

     // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));

    jQuery('image', xml).each(function(i) {
        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text()));

    });
};


function mycarousel_getItemHTML(url)

{ 
    return '<img src="' + url + '" width="75" height="75" alt="" />';
};

jQuery(document).ready(function() {
    jQuery('#futuredbc').jcarousel({

  easing: 'BounceEaseOut',
         itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
        itemLoadCallback: mycarousel_itemLoadCallback
    });
});

This method back me result like

<img width="75" height="75" alt="" src="img.jpg">

But i need to make a linked image like

<a href="http://site.com/548"><img width="75" height="75" alt="" src="img.jpg"></a>

So site.com/548 it’a i ID and i can get it from database '.$row['id'].' but i dont know how to make js and link result

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:28:14+00:00Added an answer on June 9, 2026 at 11:28 am

    The easiest way (without adding functions to resolve another XML tags (<bla>)) is just
    to add the ID to the value of the image xml tag and using a delimiter , we will split the id out of the url.

    Add the row ID to the array:

    while(($row =  mysql_fetch_assoc($res))) {
        $images[] = array('id' => $row['id'] , 'src' => '/images/'.$row['img_i'].'');
    }
    

    print it to the XML:

    foreach ($selected as $img) {
        echo '<image>' . $img['src'] . '|||'.$img['id'].'</image>';
    } 
    

    And then , repalce:

    return '<img src="' + url + '" width="75" height="75" alt="" />';
    

    With:

    var tmp = url.split('|||');
    
    return '<a href="www.site.com/'+ tmp[1] +'"><img src="' + tmp[0] + '" width="75" height="75" alt="" /></a>';
    

    Should work.
    Otherwise , comment and i’ll fix it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to make a slider but have trouble, with placing all my div
I try to make an animation with an image in my view but it
I have got a problem when I try to make following simple connections QSpinBox
I want to interrupt a thread1 from another thread2 but when I try make
I try to make a apps that need barcode scanner, i already can get
I try to make Ext.Data.Store working... With a normal proxy it works great: var
i try make some parts of page with fixed style. I have similar HTML:
I have been using the Learning Java 2nd Edtion book to try make my
Ill try and make this as clear as possible. I have a contact form
Databinding in WPF is great, but the moment you try make things more complex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.