/    Sign up×
Community /Pin to ProfileBookmark

inserting dynamic code into ajax pagination script

Hi,

I found this great tut on how to do ajax pagination. The problem is that my situation is different that his and I cant get MYSQL code to work with this script.

Here is the link [url]http://www.dynamicdrive.com/dynamicindex17/ajaxpaginate/index.htm[/url]

On the second page he explains how to pull your data to paginate from a database… well I cant get mine to work.

here is the code that I want to use to generate the data….

[code]$query1 = “SELECT * FROM video WHERE video_username = ‘$username’ ORDER BY video_upload_date DESC LIMIT $startRow,”.SHOWMAX;
mysql_select_db($database_db294582132, $db294582132);
$result1 = mysql_query($query1, $db294582132) or die(mysql_error());
// loop through DB and get basic data

while($row1 = mysql_fetch_assoc($result1)){
$video_id = $row1[‘video_id’];
$thumb = $row1[‘video_t_filename’];
$video_title = $row1[‘video_title’];
$song_name = $row1[‘video_song_name’];
$song_artist = $row1[‘video_song_artist’];
$song_unknown = $row1[‘video_song_unknown’];
$caption = $row1[‘video_caption’];
$vehicle_id = $row1[‘vehicle_id’];
$video_setup = $row1[‘setup_id’];
$upload_date = date(“m.d.’y, g:i a”, strtotime($row1[‘video_upload_date’]));
//get vehicle info
if($vehicle_id ==!NULL){
$query2 = “SELECT * FROM user_vehicles WHERE vehicle_id = ‘$vehicle_id'”;
mysql_select_db($database_db294582132, $db294582132);
$result2 = mysql_query($query2, $db294582132) or die(mysql_error());
$row2 = mysql_fetch_assoc($result2);
$year = $row2[‘vehicle_year’];
$make = $row2[‘vehicle_make’];
$model = $row2[‘vehicle_model’];
}
if($setup_id ==!NULL){
//Get setup info
$query4 = “SELECT * FROM vehicle_setups WHERE setup_id = ‘$video_setup'”;
mysql_select_db($database_db294582132, $db294582132);
$result4 = mysql_query($query4, $db294582132) or die(mysql_error());
$row4 = mysql_fetch_assoc($result4);
$setup = $row4[‘setup’];
}
//provide format for uploaded videos section
echo
‘<div id=”shopVidsDiv”><div id=”editButtonDiv”><a href=”editVideos.php”>edit</a></div>
<div id=”vehicleDescriptionDiv”><div id=”title”><span class=”videoStatHeading”>TITLE: </span>’,$video_title,'</div><div id=”Caption”><span class=”videoStatHeading”>CAPTION: </span>
‘,$caption,'</div>
<div id=”song”><span class=”videoStatHeading”>SONG NAME: </span>’,$song_name,'<span class=”videoStatHeading”> ARTIST: </span>’,$song_artist,'</div><div id=”vehicle”><span class=”videoStatHeading”>VEHICLE: </span>’,$year,’ ‘,$make,’ ‘,$model,'</div><div id=”setup”><span class=”videoStatHeading”>SETUP: </span>’,$setup,'</div><div id=”uploadDate”><span class=”videoStatHeading”>UPLOADED ON: </span>’,$upload_date,'</div></div>
<img src=”images/videoThumbs/’,$thumb,’.jpg” width=”100″ height=”75″ alt=”‘,$caption,'” />
</div>’;
}[/code]

Any ideas on where to put that code into that pagination script correctly? This is my first site ever built and I highly appreciate the help. thanks

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorFeb 04.2010 — At a first glance - a php syntax error: You have used commas (,) instead of periods (.) to concatenate php variables

For instance, instead of:
<i>
</i>echo '...&lt;/span&gt;'[COLOR="Red"],[/COLOR]$video_title[COLOR="Red"],[/COLOR]'&lt;/div&gt;...'

You should have written:
<i>
</i>echo '...&lt;/span&gt;'[COLOR="Blue"].[/COLOR]$video_title[COLOR="Blue"].[/COLOR]'&lt;/div&gt;...'
Copy linkTweet thisAlerts:
@deafboyzaudioauthorFeb 04.2010 — ok that code does work with a PHP pagination script.... do I need to use the periods instead for use in the ajax script?

I have never been able to get periods to work before and it has always frustrated me.
Copy linkTweet thisAlerts:
@KorFeb 04.2010 — ok that code does work with a PHP pagination script.... do I need to use the periods instead for use in the ajax script?

I have never been able to get periods to work before and it has always frustrated me.[/QUOTE]

I don't understand. You provided an incorrect [B]php[/B] code. In [B]php[/B], the concatenation operator is the period (.). What else do you need? You can not write a php code using javascript, it will have no effect. What, in fact, is your aim?
Copy linkTweet thisAlerts:
@deafboyzaudioauthorFeb 04.2010 — I don't understand. You provided an incorrect php code. In php, the concatenation operator is the period (.)[/quote]

Yes I have heard that and mine was working with a (,) as well, It was being used to echo variables in html code. I have changed it to periods though just to be safe.

What, in fact, is your aim? [/quote] I am trying to use the ajax pagination script thats listed at the link I provided im my first post.

I want to dynamically insert data from a database and the have the ajax pagination script sort the data into pages....

Please check out that tut at the link, its very short and organized. the SQL insertion part is on the second page at the bottom. The problem is that I cant get the syntax right for my personal situation. thanks?

would you know how to do this? I cant get the syntax correct?
Copy linkTweet thisAlerts:
@criterion9Feb 04.2010 — I don't understand. You provided an incorrect [B]php[/B] code. In [B]php[/B], the concatenation operator is the period (.). What else do you need? You can not write a php code using javascript, it will have no effect. What, in fact, is your aim?[/QUOTE]

echo is a special case where "," works nearly identically to "." because echo is translated into a function call that receives an unlimited amount of parameters. In the past (PHP 4 era) "," was used because it was faster (fractions of a second) because the call to echo with the concatenation operator (".") would cause the PHP engine to create additional variables for each concatenation. This is hardly an issue any longer since the code has been optimized long ago.


@OP:

I would take a closer look at the expected code from the tutorial and figure out how to match your output to the expected output. Otherwise you might have to adjust the processing script to work with your output (I haven't looked at the link to see what the impact might be).
×

Success!

Help @deafboyzaudio spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...