| AlexandruPaulescu a întrebat:

Salutare oameni buni am o problema pe care am sa o scriu mai in jos! Va rog sa imi explicati! nu am nevoie de link-uri etc. Cei care va pricepeti, va rog sa incercati! multumesc.

index.php :


php(pun asa, ca altfel nu se vede aici )
$connect = mysqli_connect("localhost", "root", "", "testing");
$sql = "SELECT * FROM tbl_video LIMIT 2";
$result = mysqli_query($connect, $sql);
$video_id = ";
>?
>html












Load More Data using Ajax Jquery

php
while($row = mysqli_fetch_array($result))
{
>?



php
$video_id = $row["video_id"];
}
>?

more





>html

$(document).ready(function(){
$(document).on('click', '#btn_more', function(){
var last_video_id = $(this).data("vid");
$('#btn_more').html("Loading...");
$. ajax({
url:"load_data.php",
method:"POST",
data:{last_video_id:last_video_id},
dataType:"text",
success:function(data)
{
if(data!= ")
{
$('#remove_row').remove();
$('#load_data_table').append(data);
}
else
{
$('#btn_more'). html("No Data");
}
}
});
});
});



load_data.php


php
$output = ";
$video_id = ";
sleep(1);
$connect = mysqli_connect("localhost", "root", "", "testing");
$sql = "SELECT * FROM tbl_video WHERE video_id > ".$_POST['last_video_id']." LIMIT 2";
//////////// Aici e problema! daca scot "WHERE video_id > ".$_POST['last_video_id']."", merge, dar mi le tot repeta randurile. eu vreau ca atunci cand e gata, sa se opreasca//////////////
$result = mysqli_query($connect, $sql);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$video_id = $row["video_id"];
$output.= '


'.$row["video_title"].'
';
}
$output.= '

more

';
echo $output;
}
>?



Baza de date:
--
-- Database: `testing`
--

-- --------------------------------------------------------

--
-- Table structure for table `tbl_video`
--

CREATE TABLE IF NOT EXISTS `tbl_video` (
`video_id` int(11) NOT NULL AUTO_INCREMENT,
`video_title` text NOT NULL,
PRIMARY KEY (`video_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21;

--
-- Dumping data for table `tbl_video`
--

INSERT INTO `tbl_video` (`video_id`, `video_title`) VALUES
(1, 'How to generate simple random password in php?\r\n'),
(2, 'Create Simple Image using PHP\r\n'),
(3, 'How to check Username availability in php and MySQL using Ajax Jquery\r\n'),
(4, 'How to Insert Watermark on to Image using PHP GD Library\r\n'),
(5, 'Make SEO Friendly / Clean Url in PHP using. htaccess\r\n'),
(6, 'Live Table Add Edit Delete using Ajax Jquery in PHP Mysql\r\n'),
(7, 'How to Export MySQL data to Excel in PHP - PHP Tutorial\r\n'),
(8, 'How to Load More Data using Ajax Jquery\r\n'),
(9, 'Dynamically Add / Remove input fields in PHP with Jquery Ajax\r\n'),
(10, 'Read Excel Data and Insert into Mysql Database using PHP\r\n'),
(11, 'How to Convert Currency using Google Finance in PHP\r\n'),
(12, 'Dynamically generate a select list with jQuery, AJAX & PHP\r\n'),
(13, 'How to get Multiple Checkbox values in php\r\n'),
(14, 'Ajax Live Data Search using Jquery PHP MySql\r\n'),
(15, 'Auto Save Data using Ajax, Jquery, PHP and Mysql\r\n'),
(16, 'How to Use Ajax with PHP for login with shake effect\r\n'),
(17, 'Facebook style time ago function using PHP\r\n'),
(18, 'Upload Resize Image using Ajax Jquery PHP without Page Refresh\r\n\r\n'),
(19, 'How to Search for Exact word match FROM String using RLIKE\r\n'),
(20, 'How To Create A Show Hide Password Button using Jquery\r\n');




Sau daca cumva aveti o idee despre cum as putea face "Pagination" as fi foarte recunoscator. la mine problema cea mai mare e ca nu pot sa fac sa se opreasca paginarea, imi tot repeta continutul. eu as vrea sa se opreasca. Multumesc inca odata!

2 răspunsuri:
suntserios
| suntserios a răspuns:

Acum sa nu ai impresia ca cineva sta sa iti descufreze tie codul aruncat aici. Il pui frumos intr-un ide online ceva sa poata fi citibil, dai un link, explici corect si frumos unde ai probleme si poate te ajuta careva

| AlexandruPaulescu explică (pentru suntserios):

Man stiu! am incercat de 2 ori sa scriu ce vreau... sorry