PHP Programming > General PHP Help
I need support with increment
shadowloud:
--- Quote from: ErnieAlex on March 22, 2012, 09:12:28 PM ---Well, if you are planning on using a database, it is always easier to code pages once the database is planned out and filled with some sample data. Then, the pages pull everything except pictures from the database not being created in the pages. Much easier to play with...
So, anyways, back to your page. You "create" the current versions of what is displayed from inside the passed arguments. "avatar.php?skin=1&armor=1&etc..." So these are pulled from the page in the PHP code with the $_POST['skin'], $_POST['armor'], etc... Then, you can set these are the defaults. But, if you are going to post back to the same page and display the new ones, you must POST the page back to the form page with the new settings. The page would then read the items again, getting any changes made.
Not sure if your javascript is sending the values.
I have a question about your creation of the avatars. How many skin, armor, etc are you allowing? If there 7 items with 5 options for each, that would be only 35 images. Not many. You could just store them each as avatar111111.jpg or whatever to avatar555555.jpg. Then, just use the actual picture instead of all the image drawings. Not sure about your use of this of course, only seeing a little of your code. Looks interesting. I like avatar's... LOL
Okay, so, your Javascript looks like it stays the same as you never send the variables...
So, this: "avatar.php?skin=1&armor=1&hat=1, etc
Is not : "avatar.php?skin=" & skin & ",armor=" & armor & ",hat=" hat;
Looks like the first version is sending the same number to the PHP page,
the second version is using the actual variables with the rest of the text the same...
I do not have all your code, so just guessing on how to write that last line. Just a wild guess.
You have to create the URL SRC so that it is the URL plus the arguments names= variables of the new values that were pulled with the $_POST commands and changed by next buttons...
Gee, that sounds mixed up, but, hope that makes sense to you... Good luck and let us know...
--- End quote ---
Ah, I do know about that and I did it. It is working already, since I can change my hairs to "2" at least. But I sticked those with 1 still since I am only trying to make hairs work first with the following line :
--- PHP Code: ---<? echo ++$itemid['ID'] ?>
--- End code ---
Which is not working as I would like. Used to be :
--- PHP Code: ---<? echo ++$un; ?>
--- End code ---
I am attempting to make the link echo the item id within my item table.
--- PHP Code: ---try
{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$query = new PDO('mysql:host=localhost;dbname=super', 'mario', 'bros', $pdo_options);
$itemid_query = $query->prepare('SELECT ID FROM items LIMIT 1,2');
$itemid = $itemid_query->fetch();
$itemid_query->closeCursor();
}
--- End code ---
ErnieAlex:
I got it... I know a way to fix this. I went back over all your posts (and mine, too) I am sorry, I was blind!
The screen dump of your sample shows me what I need to know...
Sorry again for taking so long to fix it... LOL...
Okay, what you want to do is load the page. when they select one of the items, it is a button.
Make the button the HREF to the new page with the changes already inside the button...
No need for any Javascript... Just the PHP posing page...
So, let's just talk about the HAIR button...
Basically it is like this:
<input value=">>" name="next_hair" type="button" onClick="sumhair()"/>
<input value="<<" name="prev_hair" type="button" onClick="neghair()"/>
change them to something like this: (Not actually, but, for talking right now...)
<a href='avatar.php?skin=1&armor=1&hat=1&face=1&item1=1&item2=1&hair=5'><input value=">>" name="next_hair" type="button" /></a>
<a href='avatar.php?skin=1&armor=1&hat=1&face=1&item1=1&item2=1&hair=2'><input value="<<" name="prev_hair" type="button" /></a>
So, to explain that. Wrapped around the button would be a direct link to send you to the avatar.php page if you press the button. The "&hair=" argument will hold the previous and next values for HAIR. I put 5 for the previous figuring you have 5 hair samples, and 2 for the next version. These are just for the sample for you to look at...
Next, inside of the avatar.php file, you would read all the values. Then, where you normally print/echo the button code above, instead you set up each of the arguments in some small code that alters each and create a new button HREF with the new values...
Did that make sense? I could make up some dummy code, but give it a try first. If you need help, post the complete two pages to me in a private-message and I will fix it for you.. I think this would work well for you... Let me know if you agree or if you want me to look further into your current way...
shadowloud:
My apologizes, it somewhat makes me sad to end up asking you to make it lol, but I must say that I can't end up getting it to work. Thing is, if I remove my JS, then buttons will href directly on avatar.php rather than only switch image to another... I don't know how to do that with PHP. Infact, I thought it was impossible. ::)
I sent you my while code so you can investiguate it better and find out.
Meanwhile I tried to create a function.. which didn't work either.
--- PHP Code: ---function itemid($query) {
$itemid_query = 'SELECT ID FROM items ORDER BY ID';
foreach ($query->query($itemid_query) as $id) {
echo $id['ID'];
}
}
$itemid = itemid(1);
--- End code ---
ErnieAlex:
Thanks for the code, I will look at it later. I PM'd you explaining. Give me a few more hours... Sorry.
Navigation
[0] Message Index
[*] Previous page
Go to full version