Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Edit join rows using a form!!!!!Help!!!!
Old 04-23-2008, 12:02 PM Edit join rows using a form!!!!!Help!!!!
Junior Talker

Posts: 2
Trades: 0
I know how to post multiple rows using a if and foreach loop. I can post multiple rows from one form.

here is the form snippet.....
Code:
<tr>
<td><input name="entry[0][place]" type="text" /></td>
<td><input name="entry[0][team]" type="text" /></td>
<td><input name="entry[0][wl]" type="text" /></td>
<td><input name="entry[0][gb]" type="text" /></td>
<td><input name="entry[0][pcage]" type="text" /></td>
<td><input name="entry[0][rs]" type="text" /></td>
<td><input name="entry[0][ra]" type="text" /></td>
<td><input name="entry[0][ags]" type="text" /></td>
</tr>
<tr>
<td><input name="entry[1][place]" type="text" /></td>
<td><input name="entry[1][team]" type="text" /></td>
<td><input name="entry[1][wl]" type="text" /></td>
<td><input name="entry[1][gb]" type="text" /></td>
<td><input name="entry[1][pcage]" type="text" /></td>
<td><input name="entry[1][rs]" type="text" /></td>
<td><input name="entry[1][ra]" type="text" /></td>
<td><input name="entry[1][ags]" type="text" /></td>
</tr>
 
 <tr>
<td><input name="entry[2][place]" type="text" /></td>
<td><input name="entry[2][team]" type="text" /></td>
<td><input name="entry[2][wl]" type="text" /></td>
<td><input name="entry[2][gb]" type="text" /></td>
<td><input name="entry[2][pcage]" type="text" /></td>
<td><input name="entry[2][rs]" type="text" /></td>
<td><input name="entry[2][ra]" type="text" /></td>
<td><input name="entry[2][ags]" type="text" /></td>
</tr>

here is the code that post it as an array of data.....
Code:
$mysql = mysql_connect($hostname, $username, $password);
mysql_select_db($database);

//? for php engine
if (isset($_POST['btnSub']))
{
 //check for records later i
    $sql = "INSERT INTO major (place,team, wl, gb, pcage, rs, ra, ags) VALUES\n ";
 
    foreach ($_POST['entry'] as $data)
    {
        $dataArray[] = "('" . join ("','", $data) . "')";
    }
    $sql .= join (",\n", $dataArray);
    /*echo '<pre>', $sql, '</pre>';    */         // view query
    mysql_query($sql) or die(mysql_error());
 header("location:ft7tinput.html"); 
 
}

How can I edit the form I tried this........
Code:
<tr>
I did this so you know what I'm trying to target....
Code:
<td><input value="<?php echo $data[0] ?>" "name="entry[0][place]" type="text" /></td>
Ok I tried to use the same if and foreach loop to edit the rows...........
Code:
<td><input name="entry[0][team]" type="text" /></td>
<td><input name="entry[0][wl]" type="text" /></td>
<td><input name="entry[0][gb]" type="text" /></td>
<td><input name="entry[0][pcage]" type="text" /></td>
<td><input name="entry[0][rs]" type="text" /></td>
<td><input name="entry[0][ra]" type="text" /></td>
<td><input name="entry[0][ags]" type="text" /></td>
</tr>
<tr>
<td><input name="entry[1][place]" type="text" /></td>
<td><input name="entry[1][team]" type="text" /></td>
<td><input name="entry[1][wl]" type="text" /></td>
<td><input name="entry[1][gb]" type="text" /></td>
<td><input name="entry[1][pcage]" type="text" /></td>
<td><input name="entry[1][rs]" type="text" /></td>
<td><input name="entry[1][ra]" type="text" /></td>
<td><input name="entry[1][ags]" type="text" /></td>
</tr>
 
 <tr>
<td><input name="entry[2][place]" type="text" /></td>
<td><input name="entry[2][team]" type="text" /></td>
<td><input name="entry[2][wl]" type="text" /></td>
<td><input name="entry[2][gb]" type="text" /></td>
<td><input name="entry[2][pcage]" type="text" /></td>
<td><input name="entry[2][rs]" type="text" /></td>
<td><input name="entry[2][ra]" type="text" /></td>
<td><input name="entry[2][ags]" type="text" /></td>
</tr>
Here is the edit code......
Code:
//? for php engine
if (isset($_GET['btnSub']))
{
 //check for records later i
    $sql = "SELECT FROM major (place,team, wl, gb, pcage, rs, ra, ags) VALUES\n ";
 
    foreach ($_GET['entry'] as $data)
    {
        $dataArray[] = "('" . join ("','", $data) . "')";
    }
    $sql .= join (",\n", $dataArray);
    /*echo '<pre>', $sql, '</pre>';    */         // view query
    mysql_query($sql) or die(mysql_error());
 header("location:ft7tinput.html"); 
 
}
When I try to look for the values to pop up it won't in the table. How do I edit rows using the same form?
flforlife is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-24-2008, 11:40 PM Re: Edit join rows using a form!!!!!Help!!!!
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
I'm admittedly a little confused by what you're asking. It looks like you're able to add content to your database, but can't allow users to edit it. If I don't understand then ignore everything after this.

I'll frequently use one HTML form page for both adding and editing. E.g.,
PHP Code:
<input name="entry[0][place]" value="<?php print $entry[0][place]; ?>" type="text" />
By looking at your SQL, it doesn't look like a multi-user app, just a form where anyone can update these entries. Either way, you should assign a primary key to the table (the entry ID) in this case. If it is just for one person, then there is no need for a secondary key (for individual users) in which case I'd just pre-populate the data manually, and replace your INSERT INTO's with UPDATE major SET ... WHERE ID=$id
__________________
Chris Duerr
AddonChat Java Chat Software

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Edit join rows using a form!!!!!Help!!!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11616 seconds with 12 queries