Jump to content

fbords

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

fbords's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i may be explaining this incorrectly. if so, i apologize, I'm still learning. the above example works for: $r = $test->getSummonerByName($summoner_name); but i would like to be able to use it for: $r = $test->getSummoner($summoner_id,'masteries'); "Masteries" is a nested property within $summoner_id. I'm trying to use kicken's decode method to echo the information but it won't work.
  2. I see. That's what I'm looking to do. What about functions with additional properties like: $r = $test->getSummoner($summoner_id,'masteries'); How would i go about accessing the "masteries" properties? The following wont work. I can't quite get the syntax right: $r = $test->getSummoner($summoner_id,'masteries'); $r = json_decode($r, true); foreach ($r as $theirname=>$details){ echo $theirname."\r\n"; echo "Masteries: ".$details['masteries']."\r\n"; }
  3. the problem is likely with my lack of expertise on the subject. My issue is pertaining to the formatting of the results that are returned. The function dumps all of the requested data, I am looking to be able to selectively choose the data displayed. So instead of it returning: {"username":{"id":585897,"name":"TheirName","profileIconId":642,"summonerLevel":30,"revisionDate":1405652924000}} I would like to choose to just show the username, id, name, etc.
  4. Hi all, I am working with the following 2 page script: https://github.com/kevinohashi/php-riot-api. All works well and the data is pulled via the API as intended. However, depending on the data I'm trying to display on screen, the object contains multiple values. For example: $r = $test->getSummoner($summoner_id,'name'); print_r($r); outputs their ID and name: {"585897":"TheirName"} Just as the following: $r = $test->getSummonerByName($summoner_name); print_r($r); outputs username, ID, Name, profile icon ID, level, and timestamp: {"theirname":{"id":585897,"name":"TheirName","profileIconId":642,"summonerLevel":30,"revisionDate":1405652924000}} Depending on which function I am calling (on example.php), I would like to be able to split the values so I can echo them throughout a page: Name: <value> ID: <value> Level: <value> etc... Any guidance would be appreciated.
  5. Sorry, I meant i CAN send you the actual pages if you want.
  6. sent the link via email, I send you the actual pages if you want as well.
  7. The Qty comes from another field in the previous page. I'll post all PHP code for your review. This is without making your original change. Form Page: <?php $Shirts = array ( //Shirt Type => Shirt Price "Cotton T-shirt $7" => "7.00", "Cotton Long Sleeve T-shirt $7" => "7.00" ); $Sizes = array ( //Shirt Size => Add'l Cost "Small (+$0)" => "+0.00", "Medium (+$0)" => "+0.00", "Large (+$0)" => "+0.00", "XL (+$0)" => "+0", "XXL (+$1)" => "+1.00", "XXXL (+$1)" => "+1.00", ); $Colors = array ( "White", "Ash", "Heather Indigo", "Yellow Haze", "Carolina Blue", "Heather Cardinal", "Vegas Gold", "Gold", "Sport Grey", "Lime", "Pistachio", "Natural", "Light Blue", "Sand", "Light Pink ", "Tangerine", "Tan", "Ice Grey", "Stone Blue", "Serene Green", "Azalea", "Daisy", "Iris", "Violet", "Dark Chocolate", "Black", "Indigo Blue", "Cedar", "Cardinal Red", "Forest", "Heliconia", "Jade Dome", "Kelly Green", "Blue Dusk", "Eggplant", "Maroon", "Olive", "Navy", "Orange", "Purple", "Chestnut", "Red", "Prairie Dust", "Royal", "Sapphire", "Charcoal", "Steel Green", "Uniform Navy", "Pine", "Military Green", "Metro Blue", "Texas Orange", "Irish Green", "Oceana", "Dark Heather", "Leaf" ); ?> <table border=0 cellpadding=0 cellspacing=0 width="100%"> <tr style="background: #eee;"> <td align="center"><strong><em>Item</em></strong></td> <td align="center"><strong><em>Size</em></strong></td> <td align="center"><strong><em>Color</em></strong></td> <td align="center"><strong><em>Qty</em></strong></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt1Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'_'.$Shirt_Price.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt1Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'_'.$Addto_Price.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt1Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt1Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt2Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt2Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt2Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt2Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt3Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt3Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt3Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt3Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt4Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt4Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt4Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt4Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt5Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt5Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt5Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt5Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt6Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt6Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt6Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt6Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt7Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt7Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt7Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt7Qty" size="2" maxlength="2"></td> </tr> <tr> <td> <?php echo '<SELECT name=Shirt8Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt8Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'>'.$Shirt_Size.'</option>'; } echo '</select>'; ?> </td> <td> <?php echo '<SELECT name=Shirt8Color> <option selected value="">---------Color---------</option>'; foreach ($Colors as $Shirt_Color) { echo '<OPTION value='.$Shirt_Color.'>'.$Shirt_Color.'</option>'; } echo '</select>'; ?> </td> <td><input type="text" name="Shirt8Qty" size="2" maxlength="2"></td> </tr> </table> The Confirmation page: <?php $Name = $_POST['Name']; $Department = $_POST['Department']; $Phone = $_POST['PhoneNumber']; $Email = $_POST['EmailAddress']; $Shirt1Type = $_POST['Shirt1Type']; $Shirt1Size = $_POST['Shirt1Size']; $Shirt1Color = $_POST['Shirt1Color']; $Shirt1Qty = $_POST['Shirt1Qty']; $Shirt2Type = $_POST['Shirt2Type']; $Shirt2Size = $_POST['Shirt2Size']; $Shirt2Color = $_POST['Shirt2Color']; $Shirt2Qty = $_POST['Shirt2Qty']; $Shirt3Type = $_POST['Shirt3Type']; $Shirt3Size = $_POST['Shirt3Size']; $Shirt3Color = $_POST['Shirt3Color']; $Shirt3Qty = $_POST['Shirt3Qty']; $Shirt4Type = $_POST['Shirt4Type']; $Shirt4Size = $_POST['Shirt4Size']; $Shirt4Color = $_POST['Shirt4Color']; $Shirt4Qty = $_POST['Shirt4Qty']; $Shirt5Type = $_POST['Shirt5Type']; $Shirt5Size = $_POST['Shirt5Size']; $Shirt5Color = $_POST['Shirt5Color']; $Shirt5Qty = $_POST['Shirt5Qty']; $Shirt6Type = $_POST['Shirt6Type']; $Shirt6Size = $_POST['Shirt6Size']; $Shirt6Color = $_POST['Shirt6Color']; $Shirt6Qty = $_POST['Shirt6Qty']; $Shirt7Type = $_POST['Shirt7Type']; $Shirt7Size = $_POST['Shirt7Size']; $Shirt7Color = $_POST['Shirt7Color']; $Shirt7Qty = $_POST['Shirt7Qty']; $Shirt8Type = $_POST['Shirt8Type']; $Shirt8Size = $_POST['Shirt8Size']; $Shirt8Color = $_POST['Shirt8Color']; $Shirt8Qty = $_POST['Shirt8Qty']; list($s1Type,$s1Price) = explode("_",$_POST['Shirt1Type']); list($s2Type,$s2Price) = explode("_",$_POST['Shirt2Type']); list($s3Type,$s3Price) = explode("_",$_POST['Shirt3Type']); list($s4Type,$s4Price) = explode("_",$_POST['Shirt4Type']); list($s5Type,$s5Price) = explode("_",$_POST['Shirt5Type']); list($s6Type,$s6Price) = explode("_",$_POST['Shirt6Type']); list($s7Type,$s7Price) = explode("_",$_POST['Shirt7Type']); list($s8Type,$s8Price) = explode("_",$_POST['Shirt8Type']); list($s1Size,$s1AddPrice) = explode("_",$_POST['Shirt1Size']); list($s2Size,$s2AddPrice) = explode("_",$_POST['Shirt2Size']); list($s3Size,$s3AddPrice) = explode("_",$_POST['Shirt3Size']); list($s4Size,$s4AddPrice) = explode("_",$_POST['Shirt4Size']); list($s5Size,$s5AddPrice) = explode("_",$_POST['Shirt5Size']); list($s6Size,$s6AddPrice) = explode("_",$_POST['Shirt6Size']); list($s7Size,$s7AddPrice) = explode("_",$_POST['Shirt7Size']); list($s8Size,$s8AddPrice) = explode("_",$_POST['Shirt8Size']); $Shirt1Total = (($s1Price * $Shirt1Qty) + ($s1AddPrice * $Shirt1Qty));// The next 3 lines aren't working properly. Will need to $Shirt2Total = (($s2Price * $Shirt2Qty) + ($s2AddPrice * $Shirt2Qty));// have up to 8 totals to add up using this formula. $Sub_Total = $Shirt1Total + $Shirt2Total; ?> <table border=0 cellpadding=2 cellspacing=2 width="100%" align="center"> <tr style="background: #eee;"> <td align="center" width="50%"><strong><em>Item</em></strong></td> <td align="center" width="20%"><strong><em>Size</em></strong></td> <td align="center" width="20%"><strong><em>Color</em></strong></td> <td align="center" width="10%"><strong><em>Qty</em></strong></td> </tr> <tr> <td align="center"><?php echo $s1Type; ?></td> <td align="center"><?php echo $s1Size; ?></td> <td align="center"><?php echo $Shirt1Color; ?></td> <td align="center"><?php echo $Shirt1Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s2Type; ?></td> <td align="center"><?php echo $s2Size; ?></td> <td align="center"><?php echo $Shirt2Color; ?></td> <td align="center"><?php echo $Shirt2Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s3Type; ?></td> <td align="center"><?php echo $s3Size; ?></td> <td align="center"><?php echo $Shirt3Color; ?></td> <td align="center"><?php echo $Shirt3Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s4Type; ?></td> <td align="center"><?php echo $s4Size; ?></td> <td align="center"><?php echo $Shirt4Color; ?></td> <td align="center"><?php echo $Shirt4Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s5Type; ?></td> <td align="center"><?php echo $$s5Size; ?></td> <td align="center"><?php echo $Shirt5Color; ?></td> <td align="center"><?php echo $Shirt5Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s6Type; ?></td> <td align="center"><?php echo $s6Size; ?></td> <td align="center"><?php echo $Shirt6Color; ?></td> <td align="center"><?php echo $Shirt6Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s7Type; ?></td> <td align="center"><?php echo $s7Size; ?></td> <td align="center"><?php echo $Shirt7Color; ?></td> <td align="center"><?php echo $Shirt7Qty; ?></td> </tr> <tr> <td align="center"><?php echo $s8Type; ?></td> <td align="center"><?php echo $s8Size; ?></td> <td align="center"><?php echo $Shirt8Color; ?></td> <td align="center"><?php echo $Shirt8Qty; ?></td> </tr> <div align="right"> <?php //get current timestamp and subtract one hour $date = time() - 3600; //output time echo date("M/d/Y, g:ia", $date); ?> </div> <tr> <td colspan="4" align="right"><strong><em>Subtotal: </em></strong>$<input type="text" name="Subtotal" size="6" maxlength="5" readonly="" style="text-align: right;" value="<? echo number_format($Sub_Total,2); ?>"></td> </tr> <tr> <td colspan="4" align="right"><strong><em>Tax:</em></strong><input type="text" name="Tax" size="6" maxlength="5" value="7.8%" disabled style="text-align: right;"></td> </tr> <tr> <td colspan="4" valign="top"><hr width="100%" size="1" style="border:1px solid thin black"></td> </tr> <tr> <td colspan="4" align="right"><strong><em>TOTAL:</em> </strong>$<input type="text" name="Total" size="6" maxlength="5" readonly="" style="text-align: right;"></td> </tr> <tr> <td colspan="4" align="center" valign="top"><em><br>Please Click Finish to Submit Your Order, or click Back to make changes.</em><br><br><input type="button" value="<< Back" onclick="history.go(-1);return false;" class="button"> <input type="submit" value="Finish >>" class="button"></td> </tr> </table> Anything you can suggest to clean this mess up will be much appreciated. I'm fairly new and am just "reinventing the wheel" I suppose.
  8. Thanks to this forum, I have gotten a little further in my script. I have a multidimensional array populating a drop down box, and I'm pulling variables from that array for my confirmation page. My Array: $Shirts = array ( //Shirt Type => Shirt Price "Cotton T-shirt $7" => "7.00", "Cotton Long Sleeve T-shirt $7" => "7.00" ); $Sizes = array ( //Shirt Size => Add'l Cost "Small (+$0)" => "+0.00", "Medium (+$0)" => "+0.00", "Large (+$0)" => "+0.00", "XL (+$0)" => "+0", "XXL (+$1)" => "+1.00", "XXXL (+$1)" => "+1.00", ); Select Boxes echo '<SELECT name=Shirt1Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'_'.$Shirt_Price.'>'.$Shirt_Type.'</option>'; } echo '</select>'; echo '<SELECT name=Shirt1Size> <option selected value="">-----Size-----</option>'; foreach ($Sizes as $Shirt_Size => $Addto_Price) { echo '<OPTION value='.$Shirt_Size.'_'.$Addto_Price.'>'.$Shirt_Size.'</option>'; } echo '</select>'; The First is a size with a base Price (ex. $7.00), depending on the Size, you may have to add an extra dollar. (See Array). To pull from the Arrays on the confirmation page I use the following: list($s1Type,$s1Price) = explode("_",$_POST['Shirt1Type']); list($s2Type,$s2Price) = explode("_",$_POST['Shirt2Type']); list($s3Type,$s3Price) = explode("_",$_POST['Shirt3Type']); list($s4Type,$s4Price) = explode("_",$_POST['Shirt4Type']); list($s5Type,$s5Price) = explode("_",$_POST['Shirt5Type']); list($s6Type,$s6Price) = explode("_",$_POST['Shirt6Type']); list($s7Type,$s7Price) = explode("_",$_POST['Shirt7Type']); list($s8Type,$s8Price) = explode("_",$_POST['Shirt8Type']); list($s1Size,$s1AddPrice) = explode("_",$_POST['Shirt1Size']); list($s2Size,$s2AddPrice) = explode("_",$_POST['Shirt2Size']); list($s3Size,$s3AddPrice) = explode("_",$_POST['Shirt3Size']); list($s4Size,$s4AddPrice) = explode("_",$_POST['Shirt4Size']); list($s5Size,$s5AddPrice) = explode("_",$_POST['Shirt5Size']); list($s6Size,$s6AddPrice) = explode("_",$_POST['Shirt6Size']); list($s7Size,$s7AddPrice) = explode("_",$_POST['Shirt7Size']); list($s8Size,$s8AddPrice) = explode("_",$_POST['Shirt8Size']); Next, I try to create individual totals: $Shirt1Total = (($s1Price * $Shirt1Qty) + ($s1AddPrice * $Shirt1Qty)); $Sub_Total = $Shirt1Total; With a little formatting I get the desired result: echo number_format($Sub_Total,2); However, if I try to add a second total, it gets disregarded: $Shirt1Total = (($s1Price * $Shirt1Qty) + ($s1AddPrice * $Shirt1Qty)); $Shirt2Total = (($s2Price * $Shirt2Qty) + ($s2AddPrice * $Shirt2Qty)); $Sub_Total = $Shirt1Total + $Shirt2Total; I have about 8 individual totals I need to add up with the same "formula" as $Shirt1Total. This is where it stops working. No matter what, it only adds up $Shirt1Total.
  9. Little Guy, your edits did the trick. May I ask you to elaborate a little bit on how this works, as I'd like to learn the best I can. Specifically, this line: list($sType,$sPrice) = explode("_",$_POST['shirt1Type']); Thanks!
  10. I was hoping someone could help a newbie with a script I'm trying to write. I have an HTML form that uses a multidimensional array to generate a select box. The array is as follows: $Shirts = array ( "Cotton T-shirt" => "7.00", "Cotton Long Sleeve T-shirt" => "8.00" ); At the drop down box, I use the following to populate all the items: echo '<SELECT name=Shirt1Type> <option selected value="">--------------Shirt Type--------------</option>'; foreach ($Shirts as $Shirt_Type => $Shirt_Price) { echo '<OPTION value='.$Shirt_Type.'>'.$Shirt_Type.'</option>'; } echo '</select>'; This all works fine. However, on my confirmation page, I want to be able to write the $Shirt_Price variable and I can't seem to figure it out. All of my other variables are retrieved when using $_POST[''], but it's a little more tricky when the value is in an array. My ultimate goal is to be able to print 7.00 if Cotton T-shirt was selected, 8.00 if Cotton Long Sleeve T-shirt was selected, etc. Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.