Zero2Cool
15 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
15 years ago
I hate PHP. Hate.
UserPostedImage
dhpackr
15 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
15 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
15 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
15 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
15 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
15 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
15 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
15 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
Fan Shout
Zero2Cool (3h) : Frigging host issues for site again
beast (3h) : For the first time in their long history, the Bears fire their head coach mid-season. Which comes after three very close in-division losses.
Zero2Cool (21h) : At the game now. Kampman and Cullen Jenkins are here.
buckeyepackfan (21h) : Happy Thanksgiving Packer Fans! Gonna celebrate with some grilled Dolphin later!
buckeyepackfan (21h) : Inactive 23 CB Jaire Alexander 56 LB Edgerrin Cooper 62 OL Jacob Monk 87 WR Romeo Doubs
dhazer (21h) : Just a talking point, do we try and trade Jaire next year to get out from the contract as he can't stay healthy
Zero2Cool (22h) : Happy Thanksgiving! About to head to game.
wpr (23h) : Happy Thanksgiving
Martha Careful (28-Nov) : Happy Thanksgiving Everybody...Go Packers!!!
Zero2Cool (28-Nov) : That is what a lot of people seem to think. Even though when he was on Giants, he was trash.
Martha Careful (27-Nov) : Brilliant move by Vikings!!! The signing provide great leverage in Darnold negotiations
Mucky Tundra (27-Nov) : Boo!
Zero2Cool (27-Nov) : Packers have ruled out Jaire Alexander, Edgerrin Cooper, and Romeo Doubs for Thursday's game against the Dolphins.
Zero2Cool (27-Nov) : Daniel Jones joins Vikings
Zero2Cool (27-Nov) : Tomorrow high 32° and low 19°
beast (27-Nov) : Thanks Mucky!
Mucky Tundra (27-Nov) : beast, forecast is looking like 27-28 degrees at kickoff, slight chance of snow flurries
Zero2Cool (27-Nov) : Oh? It wasn't on the injury report. That sucks, but it's what is best.
packerfanoutwest (26-Nov) : Doubs is out due to concussion
beast (26-Nov) : What does the weather look like?
Martha Careful (26-Nov) : You can wear long-johns mittens and a hat. We want Hill and their other skill guys FROZEN
Zero2Cool (26-Nov) : I'm not sure I hope for that. I'll be at the game.
Martha Careful (25-Nov) : I hope it is colder than a well-diggers ass on Thanksgiving night.
Zero2Cool (25-Nov) : doubt he wants to face the speedsters
beast (25-Nov) : Dolphins offense can be explosive... I wonder if we'll have Alexander back
Zero2Cool (25-Nov) : No Doubs could be issue Thursday
Mucky Tundra (25-Nov) : Bears. Santos. Blocked FG
Zero2Cool (24-Nov) : Bears. Vikings. OT
Mucky Tundra (24-Nov) : Thems the breaks I guess
Mucky Tundra (24-Nov) : Two players out and Williams had an injury designation this week but Oladapo is a healthy scratch
Zero2Cool (24-Nov) : Packers inactives vs 49ers: • CB Jaire Alexander • S Kitan Oladapo • LB Edgerrin Cooper • OL Jacob Monk
TheKanataThrilla (24-Nov) : Aaron Jones with a costly red zone fumble
Zero2Cool (24-Nov) : When we trade Malik for a 1st rounder, we'll need a new QB2.
packerfanoutwest (23-Nov) : Report: Aaron Rodgers wants to play in 2025, but not for the Jets
beast (23-Nov) : That's what I told the Police officer about my speed when he pulled me over
packerfanoutwest (23-Nov) : NFL told Bears that Packers’ blocked field goal was legal
packerfanoutwest (22-Nov) : 49ers are underdogs at Packers, ending streak of 36 straight games as favorites
Zero2Cool (22-Nov) : 49ers might be down their QB, DL, TE and LT?
packerfanoutwest (22-Nov) : Jaire Alexander says he has a torn PCL
Zero2Cool (20-Nov) : Even with the context it's ... what?
Mucky Tundra (20-Nov) : Matt LaFleur without context: “I don’t wanna pat you on the butt and you poop in my hand.”
beast (20-Nov) : We brought in a former Packers OL coach to help evaluate OL as a scout
beast (20-Nov) : Jets have been pretty good at picking DL
Zero2Cool (20-Nov) : He landed good players thanks to high draft slot. He isn't good.
Zero2Cool (20-Nov) : He can shove his knowledge up his ass. He knows nothing.
beast (20-Nov) : More knowledge, just like bring in the Jets head coach
Zero2Cool (19-Nov) : What? Why? Huh?
beast (19-Nov) : I wonder if the Packers might to try to bring Douglas in through Milt Hendrickson/Ravens connections
Zero2Cool (19-Nov) : The Jets fired Joe Douglas, per sources
packerfanoutwest (19-Nov) : Jets are a mess......
Please sign in to use Fan Shout
2024 Packers Schedule
Friday, Sep 6 @ 7:15 PM
Eagles
Sunday, Sep 15 @ 12:00 PM
COLTS
Sunday, Sep 22 @ 12:00 PM
Titans
Sunday, Sep 29 @ 12:00 PM
VIKINGS
Sunday, Oct 6 @ 3:25 PM
Rams
Sunday, Oct 13 @ 12:00 PM
CARDINALS
Sunday, Oct 20 @ 12:00 PM
TEXANS
Sunday, Oct 27 @ 12:00 PM
Jaguars
Sunday, Nov 3 @ 3:25 PM
LIONS
Sunday, Nov 17 @ 12:00 PM
Bears
Sunday, Nov 24 @ 3:25 PM
49ERS
Thursday, Nov 28 @ 7:20 PM
DOLPHINS
Thursday, Dec 5 @ 7:15 PM
Lions
Sunday, Dec 15 @ 7:20 PM
Seahawks
Monday, Dec 23 @ 7:15 PM
SAINTS
Sunday, Dec 29 @ 12:00 PM
Vikings
Saturday, Jan 4 @ 11:00 PM
BEARS
Recent Topics
1h / Green Bay Packers Talk / bboystyle

3h / Green Bay Packers Talk / Mucky Tundra

9h / Green Bay Packers Talk / wpr

27-Nov / Green Bay Packers Talk / beast

27-Nov / Green Bay Packers Talk / wpr

26-Nov / Featured Content / Martha Careful

26-Nov / Green Bay Packers Talk / Mucky Tundra

25-Nov / Green Bay Packers Talk / Zero2Cool

25-Nov / Green Bay Packers Talk / buckeyepackfan

24-Nov / Green Bay Packers Talk / buckeyepackfan

24-Nov / GameDay Threads / Zero2Cool

23-Nov / Green Bay Packers Talk / dfosterf

23-Nov / Green Bay Packers Talk / Zero2Cool

21-Nov / Green Bay Packers Talk / Martha Careful

21-Nov / Green Bay Packers Talk / Zero2Cool

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