|
-
Aug 10th, 2008, 09:14 PM
#1
Thread Starter
New Member
[RESOLVED] PHP Help please!
So, I have a script that will allow users to post their account items onto a database where other users can post their items/ game currency onto the trade..... I'm sure it was hard to understand any of that, it's hard to explain. Anyway, the page where you put your items to trade is a page where i have a checkbox generated for each item you have. For example:
Code:
while($itemname = $getinvitemsres->fetch_assoc())
{
$id = $itemname['item_id'];
$user_ownid = $itemname['id'];
$getiteminfoagain = "select * from items where id = '".$id."'";
$getinfoagainres = $db->query($getiteminfoagain);
while($infoirem = $getinfoagainres->fetch_assoc())
{
$itemnamelol = $infoirem ['name'];
$itemidid = $infoirem ['id'];
$description = $infoirem['description'];
$rarity = $infoirem['rarity'];
$otheringo = $infoirem['other'];
$image = $infoirem['image'];
echo "<tr>
<td width='15%' align='center' valign='middle' style='border: 1px solid #CCCCCC;'><input type='checkbox' name='UNKNOWN' value='$itemnamelol'></td>
<td width='85%' valign='middle' style='border: 1px solid #CCCCCC;'><img src='/images/items/$image' width='85' height='85' alt='$description'>
$itemnamelol - <font color='green'>$rarity</font> <font color='orange'>$otheringo</font></td>
</tr>";
}
}
echo "</table><input type='submit' value='Create trade!' name='submit' /></form></center>";
that code gets all of the users items from their item table and puts them next to a check box. if you check the checkbox that item will be up for trading... ect. But, the problem i'm having is: since its unknown what the item is or what the value of the checkbox will be (its based on what the user has in their inventory) how can I get the value of the checkbox into an array (an array because it needs to be different for each of the items checked) and then I wull be able to use that array to continue on with the trading... If this doesnt make sense then please tell me so I can revise my post. Thank you so much in advance this helps a lot!
Last edited by Pankirk; Aug 11th, 2008 at 01:02 AM.
-
Aug 10th, 2008, 09:18 PM
#2
Re: PHP Help please!
to array a checkbox do this:
HTML Code:
<input type='checkbox' name='mycheckbox[]' value='peanuts'>
notice the name of the checkbox.
My usual boring signature: Something
-
Aug 10th, 2008, 09:21 PM
#3
Thread Starter
New Member
Re: PHP Help please!
Sorry, I don't think I get what your saying... Would that have a point though? If I have the checkbox name in an array can I then post it to the next page and will the values of the checkbox be in an array because the name is in an array? And if thats correct, then I don't think I know how to put the name of the checkbox into an array because thats not the way that i'm echoing the data?
-
Aug 10th, 2008, 09:25 PM
#4
Re: PHP Help please!
that is how you do it. according to your code, it should look like this:
Code:
<input type='checkbox' name='itemname[]' value='$itemnamelol'>
HTML will automatically make it an array when posting it.
My usual boring signature: Something
-
Aug 10th, 2008, 09:30 PM
#5
Re: PHP Help please!
 Originally Posted by Pankirk
If I have the checkbox name in an array can I then post it to the next page and will the values of the checkbox be in an array because the name is in an array?
If the field names end with [] then PHP will automatically create arrays when populating the $_POST variable.
-
Aug 10th, 2008, 11:32 PM
#6
Re: PHP Help please!
 Originally Posted by penagate
If the field names end with [] then PHP will automatically create arrays when populating the $_POST variable.
which is what i said one post before you...
My usual boring signature: Something
-
Aug 11th, 2008, 12:26 AM
#7
Re: PHP Help please!
Sort of, but it's nothing to do with HTML, or even HTTP. It's a PHP feature.
-
Aug 11th, 2008, 12:27 AM
#8
Re: PHP Help please!
oh. i thought that the form did something before it sent it...
My usual boring signature: Something
-
Aug 11th, 2008, 12:28 AM
#9
Thread Starter
New Member
Re: PHP Help please!
Thank you very much for your replies guys! I will be back later if I have any more questions! Great help I really appreciate it!
-
Aug 11th, 2008, 12:31 AM
#10
Re: PHP Help please!
well then please mark this thread as resolved as a courtesy to others.
My usual boring signature: Something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|