Click to See Complete Forum and Search --> : add rows to the top of the table
Daria
11-20-2003, 01:41 PM
Coming from:
http://forums.webdeveloper.com/showthread.php?s=&threadid=18511
how to add rows to the TOP of the table? Is it possible at all?
Khalid Ali
11-20-2003, 05:47 PM
you should be able to that using javascript at run time in the browser by using DOM methods such as
insertBefore()
or
insertNode()
And of course you can add rows anywhere you want using php...;)
Daria
11-20-2003, 07:18 PM
Ugum, exactly - I want to modify that particular one so it adds on the top, but I don't know how. "arhhh, feel too dumb...."
I modified it for you... :)
Attached is the latest version, which can also be viewed at http://www.infinitypages.com/temp/table_text.htm
Daria
11-20-2003, 08:08 PM
You are the best!
thanksies.
You're very welcome... :)
Daria
11-21-2003, 10:14 AM
Got tied up yesterday... tested today. "Just what the doctor ordered". Thanks again, man.
Daria
11-23-2003, 01:33 PM
Follow-Up question:
I know that you have to back slash apostrophy and quotation marks when echoing.
However, I don't know (and I can't find, believe it or not, any info) how to avoid automatic backslashing when submitting a form.
Using this code for example, if I put anything with apostr. in the textfield, , for example It's a good day it comes out with a backslash in front of it, such as It\\'s a good day. If I treat is as while echoing and put a backslash on the input, it comes out with 3 backslashes.
I don't know how to avoid it. All the info I find refers to echoing, to to input fields.
You've got a couple options. The easiest is to use stripslashes() (http://us3.php.net/manual/en/function.stripslashes.php) when you echo the content out. Other than that, you can change it in your php.ini file, with the magic_quotes_gpc (http://us3.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc) directive.
Daria
01-07-2004, 03:40 PM
Shamelessly stripping pyro's script :o
I just need a simple function: how can I get it to add to the top of the row by default?
Just change this:
Top: <input type="radio" name="top_bottom" value="top"><br>
Bottom: <input type="radio" name="top_bottom" value="bottom" checked="checked"><br>
To:
Top: <input type="radio" name="top_bottom" value="top" checked="checked"><br>
Bottom: <input type="radio" name="top_bottom" value="bottom"><br>
Daria
01-07-2004, 04:06 PM
That answer I know :) thanks to you.
However,
What if I don't even want to giv'em a choice? Just plop it right on top without radio buttons?
Look for this part:
if (isset($_POST['submit'])) { #if we submitted the new row form
if ($_POST['top_bottom'] == "top") {
preg_match("/(<table(.*?)>)/is", $file, $matches);
$tableheader = $matches[0];
list($start, $end) = preg_split("/<table(.*?)>/i", $file);
$start .= $tableheader;
$new = "<tr>";
for ($i=0; $i<count($_POST)-2; $i++) { #loop through the $_POST variables
$new .= "<td>".$_POST["column_$i"]."</td>";
}
$new .= "</tr>";
$data = $start.$new.$end;
}
else {
list($start, $end) = split("</table>", $file);
$end = "</table>".$end;
$new = "<tr>";
for ($i=0; $i<count($_POST)-2; $i++) { #loop through the $_POST variables
$new .= "<td>".$_POST["column_$i"]."</td>";
}
$new .= "</tr>";
$data = $start.$new.$end;
}
}
and change it to this.
if (isset($_POST['submit'])) { #if we submitted the new row form
preg_match("/(<table(.*?)>)/is", $file, $matches);
$tableheader = $matches[0];
list($start, $end) = preg_split("/<table(.*?)>/i", $file);
$start .= $tableheader;
$new = "<tr>";
for ($i=0; $i<count($_POST)-2; $i++) { #loop through the $_POST variables
$new .= "<td>".$_POST["column_$i"]."</td>";
}
$new .= "</tr>";
$data = $start.$new.$end;
}
Then, you can also remove the radio buttons all together.
Daria
01-07-2004, 06:41 PM
I think you are looking at the different file.
Did you see my attch. from 04:40 PM? I need that particular file modified and I can't figure it out.
Sorry about that. I assumed you were using the latest version of the file I had uploaded. Here's what to do:
Change this:
list($start, $end) = split("</table>", $file);
$end = "</table>".$end;
$new = '<tr>
<td>'.$_POST['column_one'].'</td>
<td>'.$_POST['column_two'].'</td>
<td><a href=rams/'.$_POST['column_three'].'>'.$_POST['column_four'].'</a></td>
<td>'.$_POST['column_five'].'</td>
</tr>
';
$data = $start.$new.$end;
To this:
preg_match("/(<table(.*?)> )/is", $file, $matches);
$tableheader = $matches[0];
list($start, $end) = preg_split("/<table(.*?)>/i", $file);
$start .= $tableheader;
$new = '<tr>
<td>'.$_POST['column_one'].'</td>
<td>'.$_POST['column_two'].'</td>
<td><a href=rams/'.$_POST['column_three'].'>'.$_POST['column_four'].'</a></td>
<td>'.$_POST['column_five'].'</td>
</tr>
';
$data = $start.$new.$end;
Daria
01-08-2004, 11:02 AM
I used the latest for the project I originally needed it for.
I'm trying to learn PHP now (you got me hooked) and, besides of going through a manual from php.net (still on chapter 5 - basic syntax), meanwhile I strip and play with existing scripts: this one I actually need for another project (http://www.siriustechnology.com/sites/shakword/admin/) , where your originally suggested script was more suitable (there is no edit function needed...)
I played around and got "insert a link" option (without javascript), just using text fields (put the appropriate reference in the writetable.php file).
THANKS!!!
smoochies,
D.
Ah, makes sense. Good luck learning PHP. 'tis not really that hard, just takes a bit of time. :)
Daria
01-08-2004, 11:31 AM
Works great, thanks again.
I'm gonna try to make to show a "succes" page rather then refreshing to blank. I think I can figure that one out, if not, I'll holler.
Daria
01-27-2004, 04:01 PM
I need a new spin on this one. I'm attaching the php file I "stole" from you, pyro and modified to my needs (veeeery little). I am using it for THIS PROJECT (http://siriustechnology.com/sites/shakword/admin) (click on test page)
Now I want to achieve something different. I need to be able to delete row and modify the content of the rows.
I know we had the editing covered before, but not with the delete function and not with a preset number of rows. I want to be able to keep the appearance of the textfields I have now.
Help!
Daria
01-28-2004, 12:42 PM
I guess pyro is on vacation :)
Daria
02-02-2004, 11:37 AM
I noticed pyro is back, so I'm bringing it TTT.