View Full Version : A silly little question
SilverDragonTears
03-21-2012, 11:29 PM
When I'm trying to show the adopts in a table... how can I make it so there is a break say every 6 adopts or so?
!Alive
03-22-2012, 03:29 PM
If your adopts are in a table you should just be able to insert a blank row/cell to create a break in the adoptables.
I could give you better example/code if I had your code snipit.
Though I'm still pretty new to this, so I'm not sure how much help I can be.
SilverDragonTears
03-23-2012, 03:42 AM
I'm trying to get just a certain number of adopt images per row for the sort thing so that people can sort easier with smaller images.
!Alive
03-23-2012, 02:33 PM
So your wanting columns of adoptables so that you have more than one on each row?
SilverDragonTears
03-23-2012, 02:50 PM
Yep that is what I need :)
!Alive
03-23-2012, 03:05 PM
In that case I should be able to help you, since I just reccently added columns adoptables to my site. Though you'll have to convert it to fit the new 1.3 version cause I haven't touched that yet.
Have you made any changes to the original code? Like adding the ajax sortable feature or anything?
SilverDragonTears
03-23-2012, 03:07 PM
Yea I have the sort completing working... Just need to make it so I have rows of adopts instead of one on top of the other.
!Alive
03-23-2012, 03:16 PM
Alright then. Your going to need to change both the javascript in the HTML and the formatting in the myadopts.php. Do you mind showing me your code. It will make it easier for me to tell you what and where to put the code. If not I can just pull/edit my code.
SilverDragonTears
03-23-2012, 03:21 PM
K Here is my sort script. I have it separate from the my adopts
<?php
include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("classes/class_pagination.php");
include("css/pagination.css");
include("inc/lang.php");
//***************//
// START SCRIPT //
//***************//
$id = $_GET["id"];
$act = $_GET["act"];
$more = $_GET["more"];
$page = $_GET["page"];
if($isloggedin == "yes")
{
$article_content = "<p id='activate_sort'>
Click here to sort your adoptables
</p>
<table>
<tr>
<th></th><th>Name and Type</th><th>Image</th><th>Clicks</th>
</tr>
</table>
<table id='sortable_adoptables'>";
// We need to get all of the user's adoptables from the database and display them...
$query = "SELECT *
FROM {$prefix}owned_adoptables
LEFT JOIN {$prefix}sort_adoptables
ON {$prefix}owned_adoptables.aid = {$prefix}sort_adoptables.adoptable_id
INNER JOIN {$prefix}levels
ON {$prefix}levels.thisislevel = {$prefix}owned_adoptables.currentlevel
INNER JOIN {$prefix}adoptables
ON {$prefix}owned_adoptables.type = {$prefix}adoptables.type
WHERE {$prefix}owned_adoptables.owner = '{$loggedinname}'
AND {$prefix}levels.adoptiename = {$prefix}adoptables.type
ORDER BY {$prefix}sort_adoptables.sorting_id";
$stmt = $adopts->query($query);
while($row = $stmt->fetchObject()){
if($row->usealternates == 'yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
if($row->currentlevel == 0) $image = $row->eggimage;
if($image=='') $image = $row->primaryimage;
$article_content .= "<tr id='orderaid_{$row->aid}'><td><img src='{$image}' width='20px' height='20px'></td>
</tr> ";
}
$article_content .= "</table>";
}
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);
?>
and this one?
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('body').undelegate('click').delegate('p#activate _sort', 'click', function(){
var realBg = $('table#sortable_adoptables').css('background-color');
var submitForm = '<form name="submit_order" id="submit_order" action="" method="post"><fieldset><label for="submit">Submit Changes</label><input type="submit" id="submit" value="Submit"></fieldset></form>';
$('table#sortable_adoptables').css('background-color', '#FFFF66').animate({ backgroundColor: realBg }, 'slow' ).find('tbody').sortable({ cursor: 'pointer' });
$(submitForm).insertAfter('p#activate_sort').hide( ).slideDown();
$('p#activate_sort').attr('id', 'deactivate_sort');
});
$('body').undelegate('submit').delegate('form#subm it_order', 'submit', function(event){
event.preventDefault();
var data = $('table#sortable_adoptables tbody').sortable('serialize');
$.post('ajax_sort.php', data, function(result){
$('form#submit_order').html(result).delay(5000).fa deOut('slow', function(){
$(this).remove();
});
});
$('table#sortable_adoptables tbody').sortable('destroy');
$('p#deactivate_sort').attr('id', 'activate_sort');
});
});
</script>
!Alive
03-23-2012, 04:41 PM
I made the chages to your php and the javascript. This should work. You might also want to change or remove the table that has the text for name, type, ect.
Let me know how it goes. ;3
<?php
include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("classes/class_pagination.php");
include("css/pagination.css");
include("inc/lang.php");
//***************//
// START SCRIPT //
//***************//
$id = $_GET["id"];
$act = $_GET["act"];
$more = $_GET["more"];
$page = $_GET["page"];
if($isloggedin == "yes")
{
$article_content = "<p id='activate_sort'>
Click here to sort your adoptables
</p>
<table>
<tr>
<th></th><th>Name and Type</th><th>Image</th><th>Clicks</th>
</tr>
</table>
<table>";
// We need to get all of the user's adoptables from the database and display them...
$query = "SELECT *
FROM {$prefix}owned_adoptables
LEFT JOIN {$prefix}sort_adoptables
ON {$prefix}owned_adoptables.aid = {$prefix}sort_adoptables.adoptable_id
INNER JOIN {$prefix}levels
ON {$prefix}levels.thisislevel = {$prefix}owned_adoptables.currentlevel
INNER JOIN {$prefix}adoptables
ON {$prefix}owned_adoptables.type = {$prefix}adoptables.type
WHERE {$prefix}owned_adoptables.owner = '{$loggedinname}'
AND {$prefix}levels.adoptiename = {$prefix}adoptables.type
ORDER BY {$prefix}sort_adoptables.sorting_id";
$stmt = $adopts->query($query);
$cols = 3; //the number of columns
do{
$article_content .= "<tr>";
for($i=1;$i<=$cols;$i++){
while($row = $stmt->fetchObject()){
if($row->usealternates == 'yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
if($row->currentlevel == 0) $image = $row->eggimage;
if($image=='') $image = $row->primaryimage;
$article_content .= "tent .= "
<td class='sortable_adoptables'>
<table id='orderaid_{$row['aid']}'><tr>
<td><img src='{$image}' width='20px' height='20px'></td>
<td width=50%> </td> <!-- Create gap between columns -->
</tr> </table></td>";
}
else{
$article_content .= "<td> </td>"; //If there are no more records at the end, add a blank column
}
}
} while($row);
$article_content .= "</table>";
}
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);
?>
<script type="text/javascript">
$(document).ready(function(){
$('body').undelegate('click').delegate('p#activate _sort', 'click', function(){
var realBg = $('table#sortable_adoptables').css('background-color');
var submitForm = '<form name="submit_order" id="submit_order" action="" method="post"><fieldset><label for="submit">Click and drag a Pokemon to switch it with another Pokemon.</br></br></label><input type="submit" id="submit" value="Save Changes"></fieldset></form>';
$('.sortable_adoptables')
.css('background-color', '#FFFF66')
.animate({ backgroundColor: realBg }, 'slow' )
.sortable({
cursor: 'pointer', connectWith: ".sortable_adoptables", receive: function(event, ui) {
var $this = $(this);
if ($this.children('table').length > 1) {
$this.children('table').not(ui.item).appendTo(ui.s ender);
}
}
});
$(submitForm).insertAfter('p#activate_sort').hide( ).slideDown();
$('p#activate_sort').attr('id', 'deactivate_sort');
});
$('body').undelegate('submit').delegate('form#subm it_order', 'submit', function(event){
event.preventDefault();
var data = $.map($('.sortable_adoptables'), function(v, i){
return $(v).sortable('serialize');
});
data = data.join("&");
$.post('ajax_sort.php', data, function(result){
$('form#submit_order').html(result).delay(5000).fa deOut('slow', function(){
$(this).remove();
});
});
$('.sortable_adoptables').sortable('destroy');
$('p#deactivate_sort').attr('id', 'activate_sort');
});
});
</script>
SilverDragonTears
03-23-2012, 04:58 PM
Parse error: syntax error, unexpected T_CLASS in /home/taleofdr/public_html/sort.php on line 62
???
SilverDragonTears
03-23-2012, 06:15 PM
Ok I figured out that problem... there was tent .= " that in there, lol which must have been part of article_content that was meant to be removed. But now it says:
Parse error: syntax error, unexpected T_ELSE in /home/taleofdr/public_html/sort.php on line 68
!Alive
03-24-2012, 01:06 AM
Try changing the while to a if.
this:
while($row = $stmt->fetchObject())
to this:
if($row = $stmt->fetchObject())
SilverDragonTears
03-24-2012, 01:13 AM
Ohhh yay :) Now instead of it switching the places... how do I make it just move to where I put it? Without moving the other one to where the one I'm moving is?
!Alive
03-24-2012, 01:48 AM
XD
In the HTML javascript,
Change this
$('.sortable_adoptables')
.css('background-color', '#FFFF66')
.animate({ backgroundColor: realBg }, 'slow' )
.sortable({
cursor: 'pointer', connectWith: ".sortable_adoptables", receive: function(event, ui) {
var $this = $(this);
if ($this.children('table').length > 1) {
$this.children('table').not(ui.item).appendTo(ui.s ender);
}
}
});
to This
$('.sortable_adoptables').css('background-color', '#FFFF66').animate({ backgroundColor: realBg }, 'slow' ).sortable({ cursor: 'pointer', connectWith: ".sortable_adoptables" });
And it should just move them.
SilverDragonTears
03-24-2012, 01:51 AM
It does and works but it literally puts the adopt on top of the other in the same <td> lol. That might get confusing...
!Alive
03-24-2012, 02:01 AM
Yeah I know. Which is why I had them switch places. Though once submitted(and page has been refreshed) the adoptables will snap into the proper places. *actually had to get someone else to help me with the Javascript* I don't really know how to make it do what I would ideally like. I'll let you know if/when I figure out anything new that would fix the issue.
SilverDragonTears
03-24-2012, 02:03 AM
Thanks :) For now it's fine how it is... I'm just so relieved to have the other part working. I saw you signed up, lol. Easier to actually see the problem. Is your site up? If so I'd love to take a look if you want to PM it to me.
SilverDragonTears
03-24-2012, 02:13 AM
Darnit. I was trying to do the same rows thing in the profile and it's not working... minus the sortable stuff. Just wanted the rows like in the sort page.
!Alive
03-24-2012, 02:14 PM
Yeah it is.
:usedusedused:
*sent you the link to my site*
Do you need columns on the profile? It already shows them in lines. Though you should be able to add the column formatting to them...
SilverDragonTears
03-24-2012, 02:36 PM
I figured it out for the profiles :)
!Alive
03-24-2012, 03:01 PM
Oh! That's good. ^_^
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.