VaultNetwork.netVault Network Boards
Author Topic: Ok board for PHP/SQL help? Looking to make first/previous/next/last buttons [Locked]
Raiztlin  2 stars
Title: Dick Tracy
Posts: 397
Registered: 2002-1-23 08:10:37
I'm sure there is a way of doing it. Don't have time to work on it while at work though.

A quick workaround should be to call the files 1001.jpg, 1002.jpg and so on?

 

-----signature-----
I has a flavor!
CC always welcome.
Phases_OgMaxim  1 star
Posts: 52
Registered: 2002-7-16 16:32:23
aww good thinking. *snap*.. I feel stupid not thinking of that....


Edit: That works great! And, I'm okay with it. Not to worried about having them 1.jpg 2.jpg versus 1001.jpg 1002.jpg.

 

-----signature-----
Every forum should have a Phases.
Bringing SSP back to life at http://www.superstickphase.com !
Retired AC/AC2 - Phases Og'Maxim - Leafcull
Phases_OgMaxim  1 star
Posts: 52
Registered: 2002-7-16 16:32:23
Ok, check this out.


I'm trying to wrap <?php ?> code inside of <?php ?>, I can't seem to get it to work. I'm sure I will, but if you can speed things up feel free


Here's what I'm doing. Now that everything is working awesome, and automated (thanks!!), my next goal is to get rid of the prev/first buttons if someone is on the first record 1001.jpg, and get rid of the next/last buttons if someone is on $newest.


Oooo, even better, leaving but disabling them. Can I do that? I'm sure I can. if nothing else just not <a> them..


Here are the lines:


<td width="14%" align="center"><div class="buttonwrapper"><a class="squarebutton" href="index.php?id=<?php if ($current < 1002) { echo ("1001";} else { echo ("{$prev}"; } ?>"><span>Previous</span></a></div>

<br><br><div class="buttonwrapper"><a class="squarebutton" href="/index.php?id=1001"><span>First</span></a></div></td>


<td width="72%" align="center"><?php echo ("<img src=images/{$current}.jpg>"; ?></img></td>


<td width="14%" align="center"><div class="buttonwrapper"><a class="squarebutton" href="index.php?id=<?php if ($current < $newest) { echo ("{$next}";} else { echo ("{$newest}"; } ?>"><span>Next</span></a></div>

<br><br><div class="buttonwrapper"><a class="squarebutton" href="index.php?id=<?php echo ("{$newest}" ?>"><span>Last</span></a></div></td>


i've tried wrapping all current php code in each line in a <?php if ($current = 1001) blah blah ?> and <?php if ($current = newest) blah blah ?> but it doesn't seem to be taking.


I think I also tried (it was after midnight) wrapping and then removing the inside/current <?php ?>'s and echoing and stuff and I think I confused myself but I couldn't get it right.

 

-----signature-----
Every forum should have a Phases.
Bringing SSP back to life at http://www.superstickphase.com !
Retired AC/AC2 - Phases Og'Maxim - Leafcull
Raiztlin  2 stars
Title: Dick Tracy
Posts: 397
Registered: 2002-1-23 08:10:37
You should take a look at the code I posted, as a general rule, you want as little as possible code in your HTML. Try to seperate the two, and you'll have a much easyer time working with the code later.


As for removing/disabling the buttons.


just do a simple if/else statement.


if ($current!=$newest) { //if the current comic is diffrent from the newest.

// insert code to echo the button

}else {

//do nothing

}

 

-----signature-----
I has a flavor!
CC always welcome.
Phases_OgMaxim  1 star
Posts: 52
Registered: 2002-7-16 16:32:23
Yeah, that's exactly what I had tried, several times and ways, but it seemed to conflict with the < and >'s in the echo code.. but it was also very late and I'd barely slept the night before, so I'm fixin' to start trying again fresh with some coffee to boot.





As for the code you posted - I glanced at it and it looked great! However, I want as much of this as possible to be hand wrote by me simply because:


a) helps me know my code

b) helps me learn, to type it and understand it as I go

c) kinda proud of myself


With that said, I certainly ask for help when I need it, hence your first reply that got me on my way, and the automated part (which is friggin' awesome, btw). Plus, it's all working great, and fast, right now anyway. So I don't wanna fix what isn't broke!


I guess the first thing to do from here is get the code to work right and maybe remove the buttons for testing.. or link elsewhere.. until I get it right. Then I'll make new css classes to fade the text to a grey and have it not change on mouseover.

 

-----signature-----
Every forum should have a Phases.
Bringing SSP back to life at http://www.superstickphase.com !
Retired AC/AC2 - Phases Og'Maxim - Leafcull
Raiztlin  2 stars
Title: Dick Tracy
Posts: 397
Registered: 2002-1-23 08:10:37
Disabling the buttons is pretty easy, just add disabled to it.


<input type="submit" disabled>


Btw, you should automate your starting point as well, not just the ending. You can find it at place 2 in the array. (0 is "." and 1 is ".." (dir structure) so the first actualy file should be the third value of the array, IE $array[2])

So make a function to find that one as well (that's my recomendation atleast. That way you don't manually have to go change the starting file everywhere each time you change the filename structure.


As for not incorporating my code, that's ok. (It's actually all your code, just sligthly compressed.) but you should definatly work to get the code out of the html bit.


insted of doing <asd> text text text text <?php [lots of code] echo variable [lots of code] echo variable ?> </asd>

I'd do

<?php

[lots of code]

$variable = $desired_value;

[lots of code]

$variable = $alternate_value;

?>

<asd> text text text text {php echo variable;} </asd>


Edit 3: hope that helps you along the way, as you say, you learn much better by writing your own code. But the one thing you really learn from, is REwriting your code

 

-----signature-----
I has a flavor!
CC always welcome.
Phases_OgMaxim  1 star
Posts: 52
Registered: 2002-7-16 16:32:23
This is fun, I appreciate your advice and help!


This morning and set a $first variable at 1001, but it's not automated. But that's okay because I have a -404.jpg image in there anyway that might mess that up, for when people try to mess with the ID manually and put in something other than what I have comics for.


Check it out


http://superstickphase.com/index.php?id=1022 for example


I will look back at the code you suggested once I get everything working the way I want. I'll make a(nother) backup of it working 100% the way I (currently, heh) want and then mess with it.

 

-----signature-----
Every forum should have a Phases.
Bringing SSP back to life at http://www.superstickphase.com !
Retired AC/AC2 - Phases Og'Maxim - Leafcull
Raiztlin  2 stars
Title: Dick Tracy
Posts: 397
Registered: 2002-1-23 08:10:37
oh, and about the buttons.


One way of doing it.


$output = '

[lots of html code]';

if ($current!=$newest) { //if the current comic is diffrent from the newest.

$output .= 'html to echo the button'.$page_variable_here.'more html to end the button';

}else {

$output .= 'html to echo disabled button';

}

$output .='More html';


echo $output;


If that makes any sense

 

-----signature-----
I has a flavor!
CC always welcome.
Phases_OgMaxim  1 star
Posts: 52
Registered: 2002-7-16 16:32:23
Oh, I should mention that the button's aren't traditional, they're just css/links.


But, that wouldn't seem to matter with your last post. That looks interesting..

 

-----signature-----
Every forum should have a Phases.
Bringing SSP back to life at http://www.superstickphase.com !
Retired AC/AC2 - Phases Og'Maxim - Leafcull
Raiztlin  2 stars
Title: Dick Tracy
Posts: 397
Registered: 2002-1-23 08:10:37
Phases_OgMaxim posted:

This morning and set a $first variable at 1001, but it's not automated. But that's okay because I have a -404.jpg image in there anyway that might mess that up, for when people try to mess with the ID manually and put in something other than what I have comics for.



Myes. You can always see the contents of your array by using print_r($array) your first image should have the same pos. every time, as long as the file structure remains the same.

 

-----signature-----
I has a flavor!
CC always welcome.

VaultNetwork.net is an independently operated community forum and is not affiliated with, endorsed by, or technically based on IGN, GameSpy, FilePlanet, GameStats, or the former IGN/GameSpy Vault Network.
References to VaultNetwork.net mean this site/domain. VNBoards-style presentation is a visual homage only. By using this site, you agree to the forum rules.