|
Posted by Auddog on 02/07/07 17:13
My form is created by querying my database for id, fname, lname of employees
and then I add an input box for hours worked. I want everyone that works on
the production lines listed. I then would like to be able to insert the
form information into a database. I just don't know how to do this. I'm
grasping at straws right now.
Here is my form code:
<?php
//create query
$query = "SELECT id, fname, lname FROM prod_employee where active = 'yes'";
//excute query
$result = mysqli_query($connection, $query) or die ("Error in query: $query.
".mysqli_error());
// see if any rows were returned
if (mysqli_fetch_array($result) > 0) {
// yes
// print them one after another
while (list($id, $fname, $lname) = mysqli_fetch_row($result))
{
echo " <tr>
<td><div align=center>$id</div></td>
<td>$fname</td>
<td>$lname</td>
<td><input name=$id-hours type=text size=4 maxlength=4 />
</tr>";
}
echo "</table>";
}
else {
// no
// print status message
echo "No rows found!";
}
Again thanks for any help that you can provide.
A
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.tndy6vf5qnv3q9@misant.kabel.utwente.nl...
Auddog <will_k@hotmail.com> wrote:
> I would like to know how I can break apart a variable. I'm currently
> passing the variable $id-hours and I would like to break it down. I
> would
> like to break down to something similar to:
>
> $eid = id (id part of $id-hours)
> $ehour = hours (hours part of $id-hours)
How is $id-hours formatted?
> Is this possible? I'm new to programming and just trying to get thru it
> all. Thanks for any help that you may be able to provide.
Several functions come to mind. You might want to use one of these:
- explode()
- fscanf()
- split()
- preg_match()
Not much else I can say without knowing the format.
Also, why do you have this in 1 variable? More logical would be:
$var = array('id'=> 'your_id','hours' => 'your_hours', 'foo' => 'bar');
--
Rik Wasmus
Navigation:
[Reply to this message]
|