PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Deaglex
Forum Newbie
Posts: 24 Joined: Thu Feb 24, 2005 10:15 am
Post
by Deaglex » Tue Mar 15, 2005 10:47 pm
Hi guyz,
I'm having problems with the following part of the script:
before the submit
Code: Select all
if($row[6]== 1)
{
$start = 'yes';
}
else {
$start = 'no';
}
echo "<tr bgcolor=\"$row_color\">
<td align=\"left\" >$row[0]</td>
<td align=\"left\" >$row[1]</td>
<td align=\"left\" >$row[2]</td>
<td align=\"left\" >$row[3]</td>
<td align=\"center\" >$row[4]</td>
<td align=\"center\" >$row[5]</td>
<td align=\"center\" >$start</td>
<td align=\"center\" ><select name=\"$row[7]\">
<option value=\"\">-</option>
<option value=\"1\">start</option>
<option value=\"0\">sit</option></td>
";
$row_count++;
}
$di = $row[7];
after:
Code: Select all
if (isset($_POST['submit'])) //redirect if cookie is not set
{
session_name('user_name');
session_start();
$page_title = "My Drivers";
include('./nascarheader2.inc');
$di=$_POST['di'];
$di=explode(" ", $di);
I'm getting all the right information outputed on the original. I need the $row[7] to be identified as $di for submission to the database so it can change the binary table in the DB....
Thanks
feyd | Please use Code: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 15, 2005 11:14 pm
..and $row[7] is the string 'di' ? Line 16 of the first block has the name of the selection as $row[7] .. meaning you expect $row[7] to ~always be a string 'di'. If $row[7] is not 'di' then switch line 16.
Deaglex
Forum Newbie
Posts: 24 Joined: Thu Feb 24, 2005 10:15 am
Post
by Deaglex » Tue Mar 15, 2005 11:29 pm
What I need to happen is the value that corralates with the row is
here is the HTML out put:
Code: Select all
<td align="e;left"e; >Driver 1</td>
<td align="e;left"e; >#20</td>
<td align="e;left"e; >Chevrolet</td>
<td align="e;left"e; >Zend</td>
<td align="e;center"e; >134</td>
<td align="e;center"e; >402</td>
<td align="e;center"e; >yes</td>
<td align="e;center"e; ><select name="e;8"e;><option value="e;"e;>-</option><option value="e;1"e;>start</option><option value="e;0"e;>sit</option></td>
<tr bgcolor="e;#bbbbee"e;>
<td align="e;left"e; >Driver 2</td>
<td align="e;left"e; >#0</td>
<td align="e;left"e; >Chevrolet</td>
<td align="e;left"e; >MySQL</td>
<td align="e;center"e; >145</td>
<td align="e;center"e; >293</td>
<td align="e;center"e; >no</td>
<td align="e;center"e; ><select name="e;12"e;><option value="e;"e;>-</option><option value="e;1"e;>start</option><option value="e;0"e;>sit</option></td>
I need 8 & 12 to be the $di for the driver in that particular row. so I can use it as such
Code: Select all
$query="UPDATE drivers SET starter='$var' WHERE driver_id='$di'";
After typing this out i see this is not quite the way to go and how would I get a value for ...
$var
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 16, 2005 12:00 am
name the select like so:
Code: Select all
echo '<select name="di[' . $row[7] . ']">';
When submitted, you can implode() the results of array_keys() from $_POST['di']
Deaglex
Forum Newbie
Posts: 24 Joined: Thu Feb 24, 2005 10:15 am
Post
by Deaglex » Wed Mar 16, 2005 12:32 pm
I was wondering if this would work and how could i get
$di to be multidimentional.
Code: Select all
<select name=\"di[]\"><option value=\"\">-</option>
<option value=\"".$row[7]. ", 1\">start</option>
<option value=\"".$row[7]. ", 0\">sit</option>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Mar 16, 2005 1:54 pm
to get multidimensional, just reference farther into it, basically..
di[1][name][object][24], etc, etc.
Deaglex
Forum Newbie
Posts: 24 Joined: Thu Feb 24, 2005 10:15 am
Post
by Deaglex » Wed Mar 16, 2005 2:29 pm
cool thanx.
Deaglex
Forum Newbie
Posts: 24 Joined: Thu Feb 24, 2005 10:15 am
Post
by Deaglex » Fri Mar 18, 2005 12:11 am
I'm still having trouble with getting the submited data out.
What I want this to do is to update each row with the result of the selection.. I know it has to do with the name of the select option but can't figure out how to get have a value for each of the drivers.