Zero2Cool
14 years ago
I'd like to use an array.

The array would be declared like this...
$varArray(0 to 16, 2)



$varArray(x, 1) = $strGame
$varArray(x, 2) = $strSelection

Then I'd use a for loop to go through each and send each to the db. There's more to this, obviously, but is this possible with PHP?
UserPostedImage
Zero2Cool
14 years ago
I hate PHP. Hate.
UserPostedImage
dhpackr
14 years ago
Zero,
as far as using an array, the best way to use an array would be to populate a drop down list. radio buttons and drop down lists kind of work in the same manner.

you can give the end user many choices, but only one selection will be processed.

do not make it harder than you have to. using radio buttons will work fine, you'll just need 16 variables.

the code I posted will work for you. if you want to show the selection in a db instead of a 1 or 0, maybe use a drop down list instead. like this

<tr>
<td>02</td>
<td>
<?----start php

$01s = array("Packers","Bengals");

if (empty($01s[0])) {
echo '<input type="text" name="01" class="textbox" value="' . $01. '" maxlength="255" />' . "\n";
}
else {
?>
<select name="01" class="textbox">
<option value="">-- please select --</option>
<?
// Print out position options
for ($i = 0; $i < count($01s); $i++) {
echo '<option value="' . $01s[$i] . '"';
if($01s[$i]==$01){echo " selected ";}
echo ">" . $01s[$i] . "</option> \n";
}
?>
</select>
<?
}
?>
</td>
</tr>
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
dhpackr
14 years ago

I hate PHP. Hate.

"Zero2Cool" wrote:



lol, what u learned in school only scratches the surface of programming. I was lucky to have worked with the guy that hired me out of school. Dude was completely insane. totally bipolar, but man did he know vb6, vb.net, classic asp, IIS, sql. he gave me a book on coldfusion, a 40 hour week and told me to create some database driven order forms. I did it.

next was classic asp, which I wish I could've stuck with. safe, secure database driven websites with nothing but notepad. I was given a 40 work week to create some database driven order forms, and I completed that project and 1 other. after that i did a financial program in vb6 and then another in vb.net that was sold for 5 grand multiple times.

that was in my first 6 months of work. then came ektron and vb.net. i did that and was getting really good with vb.net for bout the next 9 months when i was laid off. i really think a senior programmer got a little nervous about how I was attacking all my projects and pulled the cord on my job to try and save his.

but a month after i got laid off i got this part time php gig. no experience in php, no training, just cut loose on live web forms, and service tickets.

just stick with it and you will get it. just remember, you may be editing as many as 3-4 files and several functions in each file every time you try and add something or change something.

this program will take some maintenance, which is why I am interested. I could always use another job reference, and would be willing to write some code for you.

if you decide to whip it yourself, cool, i wish you the best.
lol, little different than vb.net and using datagrids, which BTW, I may have some Ektron opportunities coming up.

you'll be fine. put the code i gave you in the file you sent me. that file you sent to me, that is what I would consider a "TEMPLATE" file.

the validation code would go in a class file.
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
Zero2Cool
14 years ago
Why is everything so freaking complicated in PHP?

in VB ... piece of cake!

'declare array
Public strMaster(0 To 4000, 3) As String

'increment index
x = x + 1

'fill array
strMaster(x, 1) = strGrame
strMaster(x, 2) = strSelection


'and to pull the data out
For i As Integer = 0 To x
     strSendGame = strMaster(i, 1)
     strSendSelection = strMaster(i, 2)
            'do work here to send each game number and selection to db
Next x


Now why can't I do that with PHP? From what I've seen of it, PHP is a very tool enriched language but how do you increment the darn index of the array dynamically?
UserPostedImage
Zero2Cool
14 years ago

I hate PHP. Hate.

"dhpackr" wrote:



lol, what u learned in school only scratches the surface of programming. I was lucky to have worked with the guy that hired me out of school. Dude was completely insane. totally bipolar, but man did he know vb6, vb.net, classic asp, IIS, sql. he gave me a book on coldfusion, a 40 hour week and told me to create some database driven order forms. I did it.

next was classic asp, which I wish I could've stuck with. safe, secure database driven websites with nothing but notepad. I was given a 40 work week to create some database driven order forms, and I completed that project and 1 other. after that i did a financial program in vb6 and then another in vb.net that was sold for 5 grand multiple times.

that was in my first 6 months of work. then came ektron and vb.net. i did that and was getting really good with vb.net for bout the next 9 months when i was laid off. i really think a senior programmer got a little nervous about how I was attacking all my projects and pulled the cord on my job to try and save his.

but a month after i got laid off i got this part time php gig. no experience in php, no training, just cut loose on live web forms, and service tickets.

just stick with it and you will get it. just remember, you may be editing as many as 3-4 files and several functions in each file every time you try and add something or change something.

this program will take some maintenance, which is why I am interested. I could always use another job reference, and would be willing to write some code for you.

if you decide to whip it yourself, cool, i wish you the best.
lol, little different than vb.net and using datagrids, which BTW, I may have some Ektron opportunities coming up.

you'll be fine. put the code i gave you in the file you sent me. that file you sent to me, that is what I would consider a "TEMPLATE" file.

the validation code would go in a class file.

"Zero2Cool" wrote:



It's so freaking frustrating! Everything I've learned with programming, doesn't work with PHP!! I can't even figure out how to increment the index of a flipping two dimensional array.

Another reason I like VB, the IDE can be used as a tool with intellisense. I'm not so lucky with PHP, even dreamweaver is no help, lol.


I did try the code you gave me and it didn't work. It was sending '0' or '1' and if it wasn't checked, it did do anything. Not sure how I screwed it up, but I must have somewhere along the lines.

If I have to make a 16 Week##.php files, I'm down with that. But I need one to work first in the scope I'm aiming for.

I thought once I had the link issue resolved it'd be a snap because all languages use arrays in a similar fashion. WRONG! lol
UserPostedImage
dhpackr
14 years ago

Why is everything so freaking complicated in PHP?

in VB ... piece of cake!

'declare array
Public strMaster(0 To 4000, 3) As String

'increment index
x = x + 1

'fill array
strMaster(x, 1) = strGrame
strMaster(x, 2) = strSelection


'and to pull the data out
For i As Integer = 0 To x
     strSendGame = strMaster(i, 1)
     strSendSelection = strMaster(i, 2)
            'do work here to send each game number and selection to db
Next x


Now why can't I do that with PHP? From what I've seen of it, PHP is a very tool enriched language but how do you increment the darn index of the array dynamically?

"Zero2Cool" wrote:



like this
for ($i = 0; $i < count($01s); $i++) {
echo '<option value="' . $01s[$i] . '"';
if($01s[$i]==$01){echo " selected ";}
echo ">" . $01s[$i] . "</option> \n";
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
dhpackr
14 years ago



I did try the code you gave me and it didn't work. It was sending '0' or '1' and if it wasn't checked, it did do anything. Not sure how I screwed it up, but I must have somewhere along the lines.

"Zero2Cool" wrote:



ok, that is what a radio button will do. if it is checked, you will see a 1 in the database. if not a 0 will appear. then you need to add that validation function so the user has to make a selection. Next you can write a function to display the users picks on a web page. just copy and paste the code into another file to display the selection.

if you want to see the selection in the database, i would suggest using a drop down list, populate with an array and then recycle this code 15 times with different variables and different arrays.

here is two picks


<tr>
<td >Pick1</td>
<td>
<?

$01s = array("Packers","Bengals");

if (empty($01s[0])) {
echo '<input type="text" name="01" class="textbox" value="' . $01. '" maxlength="255" />' . "\n";
}
else {
?>
<select name="01" class="textbox">
<option value="">-- please select --</option>
<?
// Print out position options
for ($i = 0; $i < count($01s); $i++) {
echo '<option value="' . $01s[$i] . '"';
if($01s[$i]==$01){echo " selected ";}
echo ">" . $01s[$i] . "</option> \n";
}
?>
</select>
<?
}
?>
</td>
</tr>
<tr>
<td >Pick2</td>
<td>
<?

$02s = array("Vikings","Lions");

if (empty($02s[0])) {
echo '<input type="text" name="02" class="textbox" value="' . $02. '" maxlength="255" />' . "\n";
}
else {
?>
<select name="02" class="textbox">
<option value="">-- please select --</option>
<?
// Print out position options
for ($i = 0; $i < count($02s); $i++) {
echo '<option value="' . $02s[$i] . '"';
if($02s[$i]==$02){echo " selected ";}
echo ">" . $02s[$i] . "</option> \n";
}
?>
</select>
<?
}
?>
</td>
</tr>


like i wrote, if you want the actual selection text to show up in the database, use a dropdownlist.

a radio button will display a 1 or 0 in the database, not the text, so i think my code worked properly.
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
Zero2Cool
14 years ago

like this
[php]
for ($i = 0; $i < count($01s); $i++) {
echo '<option value="' . $01s[$i] . '"';
if($01s[$i]==$01){echo " selected ";}
echo ">" . $01s[$i] . "</option> \n";
[/php]

"dhpackr" wrote:




That is way over my head and doesn't look remotely close to what I posted (which makes sense cuz mine was in .NET), lol.

Isn't there a curly bracket missing in there? I see two open and only one close?
UserPostedImage
Zero2Cool
14 years ago
[php]$int = 0;
// see if the GET variable "picks" is set
if(isset($_GET["picks"]))
{
// if picks is equal to "yes" proceed
if($_GET["picks"] == "yes")
{
echo "<strong>You picked the following winners:</strong><br />";
// if variable $x is less than the total number of games, add 1 to $x
for($x = 0; $x <= 16; $x++)
{
// check games
if($x < 10)
{
$x = "0" . $x . "";
}
if(isset($_POST["rdoGame" . $x . ""]))
{
// do whatever you want with each game right here
if($x != "1") {echo " ";}
//echo $_POST["rdoGame" . $x . ""] . "";
$strMember = $nick;
$strWeek = "01";
$strGame = $x;
$strSelection = $_POST["rdoGame" . $x . ""] . "";
$strTimeStamp = date("Ymd : His");
$int++;
echo $int . " number.";
$varSelection[$int] = array_fill($x, $strSelection);
}
}
echo $varSelection[0][0] . " - " . $varSelection[0][1] . "<br>";
echo $varSelection[1][0] . " - " . $varSelection[1][1] . "<br>";
echo $varSelection[2][0] . " - " . $varSelection[2][1] . "<br>";

echo "<br /><br />";
mysql_close($conMySQL);
}
}[/php]


See the mess I've created? lol

If I make three selections, the three 'echo' at the bottom there should show those three selections as ...

01 - Steelers
02 - Dolphins
03 - Broncos


But for some sweet reason, the array's index is not incrementing.
UserPostedImage
Users browsing this topic
    Fan Shout
    dfosterf (9h) : For the record, I enjoy Beast and Mucky drafts
    Zero2Cool (16h) : Haha
    Mucky Tundra (17h) : No time for talking! Back to work beast!
    beast (17h) : You saw only 4,201 of my mocks? 🥺 I think that means you missed more than half of them 😢
    dfosterf (20h) : Does anyone know what Lambeau field improvements got put on hold? My guess would be for the 2025 draft
    Zero2Cool (23h) : It's like listen, you made 4,201 mocks, no shit.
    Zero2Cool (23h) : Cuz during the draft "I had them mocked there!" as if it's amazing.
    Zero2Cool (23h) : They're fun to do once in awhile. It's people who think they are "content" that annoy me.
    dfosterf (23h) : Against tbd
    dfosterf (23h) : Answer to your question is yes, it's a Thursday, will be the Chiefs aga
    dfosterf (23h) : Luckily for all concerned, I don't post them. I did one, but that was like 25 mocks ago
    Zero2Cool (23h) : NFL 2024 gonna start Sept 5th isn't it???
    Zero2Cool (23h) : Ugh... kids these days!
    dfosterf (23h) : I'm gonna go do some more mock draft hell instead 🤪
    Zero2Cool (23h) : Did we do one of those prediction threads yet for 2024 season?
    dfosterf (23h) : In my city, they are playing the nimby game, in order to keep some railroad tracks vs. 2 professional sports teams and a concert venue.
    dfosterf (27-Mar) : And/Or a city council, of which I haven't seen a good one in a very long time
    dfosterf (27-Mar) : That sounds like a Mayor, not a city.
    buckeyepackfan (26-Mar) : Packers halt scheduled 80mil upgrade of stadium until lease agreement talks are restarted
    Zero2Cool (26-Mar) : City of Green Bay puts Packers' Lambeau Field lease talks on hold
    buckeyepackfan (26-Mar) : Packers 1 of 3 teams to vote no on new kickoff rule.
    Zero2Cool (26-Mar) : Packers sign another Kicker
    dfosterf (26-Mar) : Lengthy explanation at PFF if you click the link
    dfosterf (26-Mar) : Kickoff rules officially changed.ngthy explan
    Zero2Cool (26-Mar) : lol
    Cheesey (26-Mar) : 2009? No thanks! One open heart surgery is enough!
    dfosterf (26-Mar) : Good for you!
    Zero2Cool (26-Mar) : Yes. That's the one.
    dfosterf (26-Mar) : Is that "Lady Dugan" per chance?
    dfosterf (26-Mar) : Crystal?
    dfosterf (26-Mar) : Please refresh my memory
    Zero2Cool (26-Mar) : Alan posts. Crystal back in my life. It's 2009 all over again! Lol
    Mucky Tundra (26-Mar) : BAH GAWD! THAT'S CHEESEYS MUSIC!
    Zero2Cool (25-Mar) : Gutekunst said early stages of Jordan Love contract being discussed.
    Zero2Cool (25-Mar) : Shouldn't be penalized cuz official screwed up
    Zero2Cool (25-Mar) : Yeah, challenge until you are incorrect twice.
    Zero2Cool (25-Mar) : Fining them is the goal, per the people who made the rule anyway.
    dfosterf (25-Mar) : Still waiting on the kickoff rule changes. Did hear yesterday that the touchback proposal will now be the 30 yard line, not the 35
    dfosterf (25-Mar) : Probably speed of game issues with your proposal
    dfosterf (25-Mar) : Hopefully the refs don't get in the habit of throwing flags on this
    beast (25-Mar) : I think when it comes to Challenges should get two strikes, so unlimited challenges as long as they keep winning them, but 2 wrong then done
    dfosterf (25-Mar) : Still subject to the fines etc
    dfosterf (25-Mar) : Yes, I should have been more specific. Also, they are now saying it would be a 15 yard penalty. That makes more sense .
    beast (25-Mar) : Simply fined in the week to follow
    beast (25-Mar) : I agree with one NFL official, it'll probably be like some of the helmets hits, not really called by the refs on the field but simply fined
    Zero2Cool (25-Mar) : Hip drop is not. Super confusing. Referees job is harder
    Zero2Cool (25-Mar) : Swivel hip drop is banned
    dfosterf (25-Mar) : The hip drop enforcement will be in the form of fines, etc. Not flags
    dfosterf (25-Mar) : A major foul will be enforced on the offense if there are offsetting penalties in a change of possession situation
    dfosterf (25-Mar) : Teams will receive a 3rd challenge if 1 was successful. Previously, it took 2
    Please sign in to use Fan Shout
    2023 Packers Schedule
    Sunday, Sep 10 @ 3:25 PM
    Bears
    Sunday, Sep 17 @ 12:00 PM
    Falcons
    Sunday, Sep 24 @ 12:00 PM
    SAINTS
    Thursday, Sep 28 @ 7:15 PM
    LIONS
    Monday, Oct 9 @ 7:15 PM
    Raiders
    Sunday, Oct 22 @ 3:25 PM
    Broncos
    Sunday, Oct 29 @ 12:00 PM
    VIKINGS
    Sunday, Nov 5 @ 12:00 PM
    RAMS
    Sunday, Nov 12 @ 12:00 PM
    Steelers
    Sunday, Nov 19 @ 12:00 PM
    CHARGERS
    Thursday, Nov 23 @ 11:30 AM
    Lions
    Sunday, Dec 3 @ 7:20 PM
    CHIEFS
    Monday, Dec 11 @ 7:15 PM
    Giants
    Sunday, Dec 17 @ 12:00 PM
    BUCCANEERS
    Sunday, Dec 24 @ 12:00 PM
    Panthers
    Sunday, Dec 31 @ 7:20 PM
    Vikings
    Sunday, Jan 7 @ 3:25 PM
    BEARS
    Sunday, Jan 14 @ 3:30 PM
    Cowboys
    Saturday, Jan 20 @ 7:15 PM
    49ers
    Recent Topics
    9h / Green Bay Packers Talk / dfosterf

    9h / Green Bay Packers Talk / bboystyle

    9h / Green Bay Packers Talk / bboystyle

    16h / Green Bay Packers Talk / Mucky Tundra

    21h / Random Babble / Zero2Cool

    27-Mar / Green Bay Packers Talk / beast

    26-Mar / Green Bay Packers Talk / beast

    26-Mar / Green Bay Packers Talk / beast

    26-Mar / Green Bay Packers Talk / bboystyle

    25-Mar / Green Bay Packers Talk / Zero2Cool

    25-Mar / Green Bay Packers Talk / Zero2Cool

    24-Mar / Around The NFL / dhazer

    24-Mar / Green Bay Packers Talk / beast

    24-Mar / Green Bay Packers Talk / beast

    22-Mar / Green Bay Packers Talk / beast

    Headlines
    Copyright © 2006 - 2024 PackersHome.com™. All Rights Reserved.