Hi all, I am trying to develop what amounts to a data entry page for the company I work for, (mostly to make my job easier). I think that I am beginning to grasp php, but I am at a loss now. I understand how to use HTML_Table to add a table to a page, and that portion of my project is coming along nicely. The problem is at this point, that I can't figure out how to increment the row that gets written to. Row 0 just keeps getting overwritten.
There are a lot of things here that are probably gonna seem overkill to the guys who really know what they are doing, but I am trying to teach myself, how to do this. I've added comments to the source code, to try and relay what I understand things to mean. Please correct me if I'm wrong...I am totally new at this, a a week of solid study, and this is where I am so far. Almost all of this is copied from a lesson on HTML_Table, I have been trying to tear it down, and make it work, I mostly (I think anyway) understand what is being done, but I cannot figure out how to increment from row 0, to row 1, then 2 etc...
Thank you in advance for any help and explanation, and for dealing with my probably inane questions.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>index.ph p v.04</title>
</head>
<body>
<?php
// I read that variables should be defined or set before being initialized. This is what
// I thought that they meant.
$tableDat[] = "0"
// This was the only way that I could get the different $_POST values assigned to the array
// I'm sure there is a better way, but this worked, so I stuck with it.
$tableDat[0] = $_POST['recip'];
$tableDat[1] = $_POST['address'];
$tableDat[2] = $_POST['docket'];
$tableDat[3] = $_POST['version'];
$tableDat[4] = $_POST['shipment'];
$tableDat[5] = $_POST['jobname'];
$tableDat[6] = $_POST['jobnum'];
$tableDat[7] = $_POST['envel'];
$tableDat[8] = $_POST['carton'];
$tableDat[9] = $_POST['pouch'];
$tableDat[10] = $_POST['skid'];
?>
<?php
// This section is being used for the basic layout of the table, created by HTML_table. I think
// that in order for the data to be incremented, that I should make column 0 a variable
// assigned higher up, something like $foobar = "0", and then write a small incrementer, so
// that the row number will change 0, 1, 2, etc. I tried it, and I learned in short order, I have
// very little notion of what in fact is going on here.
$data = array(
'0' => array("$tableDa t[0]", "$tableDat[1]", "$tableDat[2]", "$tableDat[3]", "$tableDat[4]", "$tableDat[5]", "$tableDat[6]", "$tableDat[7]", "$tableDat[8]", "$tableDat[9]", "$tableDat[10]"),
'1' => array(""),
'2' => array("")
);
?>
<?php
// The class inclusion and setting the attributes of the table to be made. This I get, mostly
// anyway.
require_once 'HTML/Table.php';
$tableAttrs = array('width' => '600'); // Why is this assigned to an array?
$table = new HTML_Table($tab leAttrs);
$table->setAutoGrow(tr ue);
$table->setAutoFill( 'n/a');
?>
<?php
// This section, lost me completely. I can see that this is being used to increment something
// I'm just lost on where some of this stuff is coming from, especially the $nr, is that a
// special variable? As I sit here staring at this I think i get it. $nr = 0, which I am taking is
// referring to column 0, and is incrementing it by one...ok if this is the increment step,
// why isn't it working? What did I do wrong?
for ($nr = 0; $nr < count($data); $nr++) {
$table->setHeaderConte nts($nr+1, 0, (string)$nr);
for ($i = 0; $i < 11; $i++) {
if ('' != $data[$nr][$i]) {
$table->setCellContent s($nr+1, $i+1, $data[$nr][$i]);
}
}
}
$table->altRowAttribut es(1, null, $altRow);
?>
<?php
// This is where the titles for the cells on the header row are being defined.
$table->setHeaderConte nts(0, 0, '');
$table->setHeaderConte nts(0, 1, 'Recipient Name');
$table->setHeaderConte nts(0, 2, 'Recipient Address');
$table->setHeaderConte nts(0, 3, 'Docket #');
$table->setHeaderConte nts(0, 4, 'Version #');
$table->setHeaderConte nts(0, 5, 'Shipment #');
$table->setHeaderConte nts(0, 6, 'Job Name');
$table->setHeaderConte nts(0, 7, 'Job #');
$table->setHeaderConte nts(0, 8, 'Envelopes');
$table->setHeaderConte nts(0, 9, 'Cartons');
$table->setHeaderConte nts(0, 10, 'Pouches');
$table->setHeaderConte nts(0, 11, 'Skids');
$hrAttrs = array('bgcolor' => 'silver');
$table->setRowAttribut es(0, $hrAttrs, true); // Here I am lost again, why is this true
$table->setColAttribut es(0, $hrAttrs); // and this one just is...
?>
<?php
$table->display();
?>
// This is the actual form itself. I have the action set to index4.php, so that the processed
// info will be displayed on this page.
<form action="index4. php" method="post">
<table border="0">
<tr><td valign="top">Re cipient name:<br>
<input type="text" name="recip"><b r>
Recipient Location:<br>
<textarea name="address" rows="4" cols="30" >
</textarea></td>
<td valign="top" >
Docket # <br>
Version #<br>
Shipment #<br>
Job Name:<br>
Job #<br>
</td>
<td valign="top">
<input type="text" name="docket" size="10"><br>
<input type="text" name="version" size="10"><br>
<input type="text" name="shipment" size="10"><br>
<input type="text" name="jobname" size="10"><br>
<input type="text" name="jobnum" size="10"><br>
</td>
<td valign="top">
Envelope:<br>Ca rton:<br>Pouch: <br>Skid:
</td>
<td valign="top">
<input type="text" name="envel" size="10"><br>
<input type="text" name="carton" size="10"><br>
<input type="text" name="pouch" size="10"><br>
<input type="text" name="skid" size="10"><br>
</tr></table>
<input type="submit" value="Add to logsheet">
</form>
</body>
</html>
7 1927
Welcome to TSDN.
Before you continue posting in this forum, READ THE POSTING GUIDELINES!!
Especially the part about enclosing shown code within code or php tags! You code is unreadable without an IDE. moderator
Welcome to TSDN.
Before you continue posting in this forum, READ THE POSTING GUIDELINES!!
Especially the part about enclosing shown code within code or php tags! You code is unreadable without an IDE. moderator
Thank you for the info, I read the guidelines, once, but got so flustered, it slipped my mind, my apoligies.
I am trying to set up a minimal web page, that will allow me to use a form, to input my daily log info, and php to format, display, the log onscreen. I have been successful in making everything that I have so far work, the problem is, I have not been able to figure out where our how to write a counter, to increment, which row the data gets written to. Starting at 0, then 1, then 2 etc.
Here is what I have so far.
[PHP]
$tableDat[] = "0"
$tableDat[0] = $_POST['recip'];
$tableDat[1] = $_POST['address'];
$tableDat[2] = $_POST['docket'];
$tableDat[3] = $_POST['version'];
$tableDat[4] = $_POST['shipment'];
$tableDat[5] = $_POST['jobname'];
$tableDat[6] = $_POST['jobnum'];
$tableDat[7] = $_POST['envel'];
$tableDat[8] = $_POST['carton'];
$tableDat[9] = $_POST['pouch'];
$tableDat[10] = $_POST['skid'];
$data = array(
'0' => array("$tableDa t[0]", "$tableDat[1]", "$tableDat[2]", "$tableDat[3]", "$tableDat[4]", "$tableDat[5]", "$tableDat[6]", "$tableDat[7]", "$tableDat[8]", "$tableDat[9]", "$tableDat[10]"),
'1' => array(""),
'2' => array("")
);
for ($nr = 0; $nr < count($data); $nr++) {
$table->setHeaderConte nts($nr+1, 0, (string)$nr);
for ($i = 0; $i < 11; $i++) {
if ('' != $data[$nr][$i]) {
$table->setCellContent s($nr+1, $i+1, $data[$nr][$i]);
}
}
}
$table->altRowAttribut es(1, null, $altRow);
$table->setHeaderConte nts(0, 0, '');
$table->setHeaderConte nts(0, 1, 'Recipient Name');
$table->setHeaderConte nts(0, 2, 'Recipient Address');
$table->setHeaderConte nts(0, 3, 'Docket #');
$table->setHeaderConte nts(0, 4, 'Version #');
$table->setHeaderConte nts(0, 5, 'Shipment #');
$table->setHeaderConte nts(0, 6, 'Job Name');
$table->setHeaderConte nts(0, 7, 'Job #');
$table->setHeaderConte nts(0, 8, 'Envelopes');
$table->setHeaderConte nts(0, 9, 'Cartons');
$table->setHeaderConte nts(0, 10, 'Pouches');
$table->setHeaderConte nts(0, 11, 'Skids');
$hrAttrs = array('bgcolor' => 'silver');
$table->setRowAttribut es(0, $hrAttrs, true);
$table->setColAttribut es(0, $hrAttrs);
[/PHP]
[HTML]
<form action="index4. php" method="post">
<table border="0">
<tr><td valign="top">Re cipient name:<br>
<input type="text" name="recip"><b r>
Recipient Location:<br>
<textarea name="address" rows="4" cols="30" >
</textarea></td>
<td valign="top" >
Docket # <br>
Version #<br>
Shipment #<br>
Job Name:<br>
Job #<br>
</td>
<td valign="top">
<input type="text" name="docket" size="10"><br>
<input type="text" name="version" size="10"><br>
<input type="text" name="shipment" size="10"><br>
<input type="text" name="jobname" size="10"><br>
<input type="text" name="jobnum" size="10"><br>
</td>
<td valign="top">
Envelope:<br>Ca rton:<br>Pouch: <br>Skid:
</td>
<td valign="top">
<input type="text" name="envel" size="10"><br>
<input type="text" name="carton" size="10"><br>
<input type="text" name="pouch" size="10"><br>
<input type="text" name="skid" size="10"><br>
</tr></table>
<input type="submit" value="Add to logsheet">
</form>
</body>
</html>
[/HTML]
I am not familiar with the package you are using, but can I assume that this statement - $table->setCellContents($nr+1, $i+1, $data[$nr][$i]);
is used to fill the rows of the table?
Ronald :cool:
I am not familiar with the package you are using, but can I assume that this statement - $table->setCellContents($nr+1, $i+1, $data[$nr][$i]);
is used to fill the rows of the table?
Ronald :cool:
I believe so. I am quite new to PHP, but from what I have been able to put together, that is part of a counter function, to increment the row that data is being written too. However if that is in fact what it is, it's not working. No doubt because of my lack of understanding, as to how to implement it. Most of this I got examples I found on the net as to how to use HTML_Table. I'm just not grokking it.
The main problem is that all the examples are designed around pulling the information out of a database, I'm trying to modify to accept input from a web form...
code green 1,726
Recognized Expert Top Contributor
You are trying to use a class when you obviously don't understand classes.
Drop this class, go back to basics
[PHP]$table = new HTML_Table($tab leAttrs);[/PHP]and start again, because as ronverdonk said we have no idea about the class package you are using
You are trying to use a class when you obviously don't understand classes.
Drop this class, go back to basics
[PHP]$table = new HTML_Table($tab leAttrs);[/PHP]and start again, because as ronverdonk said we have no idea about the class package you are using
I thank you for taking a look at the code anyway. I appreciate you guys taking the time to do so. If and when I manage to get this figured out, I will try to come back and relay the information that I have gained.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Antoni |
last post by:
Hello,
I wondered if anyone could offer some guidance, I trying to write a
php script to connect to a database, and display the records in a
table.
I found the code here in a php4 text, and when I run this directly
through the php intrupeter, the line Successfully connected is display
and 4 as the number of rows.
|
by: Robbie |
last post by:
Hi to everyone,
I'm relatively new to php and to PEAR in particular.
I'm using PEAR, especially the HTML_Table package. It's almost clear
how the things work, but I've a question for which I'll appreciate
your opinions.
I fetch some record from a MySQL db and print them out on a table with
addRow() method: no problem until here.
|
by: Tom |
last post by:
Anyone help on this? PHP/MySQL
I have a repeat region displaying records from orders in a CSV format:
CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBSITE,CA,Book,25.95,???
CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBSITE,CA,Poster,10.00,???
CalJoe33,18,08/23/2004,FED EX,PREPAID,WEBSITE,CA,Video,49.95,???
I need to have a column where I can assign each item in the order a
different number incrementally i.e. 1st item = 1, 2nd = 2 etc.
|
by: macluvitch |
last post by:
Hello folks,
During developping I've met a problem this is how it looks like
I have an expression like this
(type *)var + 1
Wath heppens is I want to make a pointer to this
|
by: Thomas G. Marshall |
last post by:
Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> coughed up the following:
> On Thu, 1 Jul 2004, Thomas G. Marshall wrote:
>>
>> Aside: I've looked repeatedly in google and for some reason cannot
>> find what is considered to be the latest ansi/iso C spec. I cannot
>> even find C99 in its final draft. Where in ansi.org or the like do
>> I find it?
>
> The official C99 specification is copyright ISO and distributed by
> various national...
| |
by: Erik de Castro Lopo |
last post by:
Hi all,
The GNU C compiler allows a void pointer to be incremented and
the behaviour is equivalent to incrementing a char pointer.
Is this legal C99 or is this a GNU C extention?
Thanks in advance.
Erik
|
by: Julien Sobrier |
last post by:
Hello,
I can't install the pear package HTML_Table:
# pear install HTML_Table
Warning: xml_parse() http://www.php.net/function.xml-parse]: Unable to
call handler _pkginfo_cdata_2_0() in Common.php on line 758
(above error message several times)
The following errors where found (use force option to install anyway):
missing package name
|
by: John Doe |
last post by:
I have a not-so-large double in the range 1-1000, but with fractional
part. I only do ++my_double to increment it, however sometimes it
happens that after incrementing
int(old_double) == int(new_double)
why? Again the doubles are not large at all, their exponents cannot be
so high to shift out the 1 I add out when incrementing and we have 64
bits to use here.
|
by: subramanian100in |
last post by:
The following portion is from c-faq.com - comp.lang.c FAQ list ·
Question 6.13
int a1 = {0, 1, 2};
int a2 = {{3, 4, 5}, {6, 7, 8}};
int *ip; /* pointer to int */
int (*ap); /* pointer to array of int */\
ap = &a1;
printf("%d\n", **ap);
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |