Form / Table Classes
Do any of you guys know of a good form/table class combination to easily throw forms with embedded tables up to the screen? I've been trying to write one and it's a little more complicated than I originally thought.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Outputting A Table Or Form Using SHOW FIELDS FROM Table
In the code the MySQL database was queried using "SHOW FIELDS FROM table" which and the returned results of column names was then use to build an output for a form and a table with php using a series of if statements along the lines of if the returned field name matches something echo a text input field. I have never seen this done this way before, so I want to get the opinion of the devshed user. Does it seem like an unsual long process to build up a form. Is there a security advantage doing it this way? Has anyone ever done it this way before?
Static Classes Vs. Singleton Classes Vs. Globals
Sometimes I want to use certain data and functions anywhere in my code; for example, when writing logging routines. In PHP5 I could write a class with all static members and functions, a singleton class, or a regular class assigned to a global variable. What would be the advantages of each? In Java web-apps (or in non-web applications), these classes persist for much longer, so it's easier to see the reasons for using them. But in PHP, it seems like you could do pretty much the same thing with all three.
SELECT * Form Table WHERE Function(??) BETWEEN ?? & ??
I have a CHAR(50) field in my table. This field stores datetimes in this format (i have no options to modify this stuff). 2001-02-16 00:00:00 Does anyone have an idea about how to make a function which allow me to: - The user inputs two dates in 2 input boxes...like these: 2001/02/16 & 2001/06/14 (or maybe user inputs data like 2001-02-16 & 2001-06-14) (i must check with javascript how the data is entered and then parse the 2 input boxes). Then i must list all data between 2001/02/16 & 2001/06/14 querying the table i told before.Does anyone have a good idea to do this?
Can't Update Mysql Table Via Php Form
I have a form that updates an item pulled from a database, but after the form is posted, it does not update the mysql database with the new info, here's what I am using: Code:
Form Data Array - Need To Update Table
I have a form that is dynamically generated by the fields I have in a table. This table generates the navigation for my site, and I want to create a page that will allow me to reorder and hide/show and activate/deactivate the links. The form is working and I have the form generating an array based on the data collected on submit. I need to know how to break this data apart so I can update my site navigation table with the correct values. The table looks like this:
Adding Thumbnails In A Table With Php From A Form And Opening....
I have an image uploader that works and i then want to use the images uploaded in a form which adds stock. i already have an add stock form but i want to add a new field and state the path of the image and then display the image as a small thumbnail in a table on another page and then wen the thumbnail is clicked on i would like it to enlarge in a small popup window. it seems like quite a mission to me and no matter what i do i cant get it to worhelp. Code:
PHP Form Overwrites MySQL Table Data
I have a PHP form sending data to a MySQL table, and I am wondering if I can add some sort of code to the PHP page that will make the form data overwrite any potentially old data already in the table.
Display Values Of The Form Inside The Table On The New Page
I am generating data from database and displaying it inside input text boxes (for users to make some changes). What I need to do is when user presses "submit" button display all of the results inside the table on the new opened page. How can I do it?
Create A Data Entry HTML Form For Given Table
I am working on a simple web site updating utility for a web site. Rather than hard code the data entry forms, I would like to automactically generate them based upon the table a user selects to update or insert into. What is the best way to approach this? for "insert" should I use the MySQL DESCRIBE table command and build a form element for each field according to its data type? for "update" should I use the DESCRIBE command to build the form as above and SELECT statement to populate each element with data, or should I just use a SELECT statement to retrieve the data and use php to determine the field type and choose an appropriate form element?
A Tool For Form Generation Based On A Mysql Table.
I'm looking for a tool that auto generates forms based on a mysql table. I need an interface that will allow: 1. picking a list of columns from the table (so a form that inputs only part of the table's columns is possible to generate). 2. picking a set of validation rules out of a predefined set of possible validators. An example usage of the tool will allow a webmaster to alter the details required for users sign up in two steps: 1. altering the mysql table adding some new columns. 2. picking which of the new columns should be requested in the signup form and how to validate each. After the second step the signup form will be automatically updated. Before starting to write such a tool I want to make sure that it doesn't already exist. Searching the web I found two similar projects: phpMyEdit(http:// www.phpmyedit.org/), and PHP Form Generator(http:// www.phpformgen.com). But both don't allow what I described above.
Generate An Html Form, To Be Submitted For Insertion To A 3rd Table
1. display a form consisting of radio buttons and check boxes. multiple selection of check boxes per radio button basically. I got this part done, it displays the data in the form which is being pulled from two separate tables. 2. Insert for each check box a record into a third table of the check box and radio button. this is what i have thus far and I'm not really sure why it's not working from what i can see step by step it should be inserting the records, these arrays are the most terrible thing i can think of having to do. Code:
Using Classes Inside Of Other Classes
I'm wondering how to use another class inside a preexisting class, without passing the constructor in the preexisting class an object from a file that contains a new declaration. IE: Instead of doing something like this...
Table Based Order Form That Can Email Text Entered?
I have a custom order form that I collaborated on with a friend who knows php. The form needs updated and the code we put together is hard for me to read and update. I think the form can be refined or rewritten in a more OOP way and hopefully as sematic as possible. The Form is for entering ready made frames. The Choices are color and size. Here is what I need to do: Enter Name, Email, Store Number, Comments Etc.Create a table based form where users can only enter numbers in each text field.Upon completion, agreement, and submission of the order an html email is kicked to our inbox. The table remains as it was on the website due to html and a separate print css file. Code:
Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?
Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for. Can anyone help me get the Agreed? table's background color to the colors above? Code:
Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table is to fields on is ID and the other is critiera. Now I want to filter out all the one that don't apple to the list and move the one that match to a different database. I know how to open a connection, close, select but I don't know how I would inside of a database use another one as the way to create the list of critieras....
Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias' the mysql_fetch_field function returns a value $result=>table which will contain the alias, not the actual table name. Is there a way to get the actual table name ? I am running mysql 4.1 and php 4.4
Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'. There is one of each item in products and each product has it's own unique 'prodno' There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example: id = 1 prodid = 7001 qty = 300 price = 12.5 id = 2 prodid = 7001 qty = 400 price = 15.5 I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table. Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item.. This is all very confusing to me, and I'm the one writing it. Let's try one last time.. Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.
Update Table While Insert Data To Another Table
it seem like mine coding din work. [php]<? include("checkin.html"); $conn=mysql_connect('localhost','root','') or die ('Could not connect to server'); $today = date("Y.m.d"); mysql_select_db('hms', $conn); $ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn); if( $ok ){ $up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID'); if(mysql_affected_rows( $up ) == 1) { echo'Checked IN!' }else { echo'No such student to check in' }} else { echo'Check In FAILED, please check again'}?>[php]
Why Use Classes?
I feel that i mastered functions and now there is something called classes. What makes it superior to functions? Is it better to use them?
PDF , Classes, And PHP
I'm stuck at first base here. Currently working on turning a rather static PDF building script into a more modular, OO PHP app. I have scaled this example down to the bare bones, trying to see what the heck is going wrong. It recognizes that is should spawn a pdf file, but then there is just no data. Nothing, no error, no helper app. I'm only a week or so into PDFs and only a couple of days into OO with PHP, so I'm on the lookout for the obvious. I do have PHP/PDF apps that run fine off the same system. Here is the class: <? error_reporting(E_ERROR); /******************************************** pdfReport.class.php - description ********************************************/ /* common functions / classes */ //class used to build rectangles - how exciting (-: class pdfReport{ //define our common properties //page properties var $pdf; function createPDF() { header("Content-type: application/pdf"); header("Content-Dispositions: filename=report.pdf"); $this -> pdf = pdf_open(); pdf_begin_page($pdf, 612, 792); }//end function createPDF function closePDF() { pdf_close($pdf); }//end function pdf_close function buildText() { pdf_set_font($pdf, "Times-Roman", 15, "host"); pdf_show_xy($pdf, "Active Case Review Quarterly Report", 25, 780); pdf_set_font($pdf, "Times-Roman", 26, "host"); }//end function buildText }//end class ?> And here is the page where I call the class: <? include("test.class.php"); //error_reporting(E_ERROR); //create a report $quarterlyPDF = new pdfReport; $quarterlyPDF -> createPDF(); $quarterlyPDF -> buildText(); $quarterlyPDF -> closePDF(); //end pdf document ?> thanks much for any input.
Value Of PHP Classes?
So PHP classes are pretty cool. But what is the value they provide? I understand the value of OO, but in the PHP environment, every class you instantiate lives only in the span of that request. There is no concept of singleton classes, or classes that remain across requests. The notion of allocating new memory for every instance of a class for every request seems wasteful. Thoughts?
Why Uses Classes?
I've read a DevShed article about classes in PHP, but still can't see a practical application for them considering you can use functions throughout your script, or (such as classes) include classes for certain scripts. Can anyone tell me clearcut, what they are and why I'd use one, and in what instance?
Classes
I've been introduced to the concept of classes in PHP. Everyone says that they're the essence of object oriented programming and that they are extremely useful. Could someone give me an example of a good use of classes?
Classes - Why Would I Want To Use Classes In PHP?
okay, this is really (!) embarassing, but I have to ask: Why would I want to use classes in PHP? I have been using PHP for years now and writing the "normal" functions all the time. I have never even bothered working with classes, but now I would love to know what makes the classes so special......
DIR CLASSES Wth Is This?
ok, I have the following code: this file is called cont.php: <?php require_once(DIR_CLASSES . 'container/containerbase.php'); . . class Container extends Containerbase { . . . class def's . . } ?> Now nowhere in the containerbase.php file is the value DIR_CLASSES defined and its not some PHP global value. I also have no common.inc file that might define this value. Where/How do I define the DIR_CLASSES value?
Using PHP Classes ... When?
I have been using PHP for a few years but never used classes. I understand how they are created and how they work but was unsure about when you use them.
Php Classes Within Classes?
I've been programming PHP for about 2 years and have dabbled with classes. I'm working on a project and can't seam to figure out how to use classes within classes. For example: --foo.class.php-- <? class Foo { var $test1; function Foo() { require_once('bar.class.php'); $test1=new Bar(); } function testFooBar() { return $this->test1->testBar(); } } ?> --bar.class.php-- <? class Bar { var $return; function Bar() { $this->return='FooBar Works!' } function testBar() { return $this->return; } } ?> --index.php-- <? require_once('foo.class.php'); $test = new Foo(); echo $test->testFooBar(); ?> index.php will disply a blank page instead of 'FooBar Works!'.
Classes... Why?
why would i use a class in php, and how do i use a class in php?
Classes
Well I want to use classes and ive used them before in Visual Basic, C++, and Java but not for PHP if I create a class what will keep it alive from page to page (because all variables die from one page load to the next)
OOP PHP Classes
I was interested in looking at some php5 classes and objects that are object orientated to get an idea of what other people are doing. But more "real world" examples, more than "class FruitBowl" if you know what I mean by this. Does anyone have any links handy for something like this?
PHP Classes
What is a PHP class? I've seen a lot of talk about these and how they can help you out, but I've never seen a very good explanation. I've been working with PHP for just over 6 months and usually hard code everything into my scripts. Recently I've begun putting frequently-used things (like my MySQL connect function) in a seperate file and including them. But I still haven't seen the use of classes or even functions for that matter. And one more thing - how do you set up a function to accept variables?
PHP Classes :: & ->
What is the difference between "::" and "->" when using classes? It always hard to find documentation for something that i only a symbol.
Use And Need Of Classes In PHP
I know what object oriented programming is - I know what classes are and how they work - I'm just trying to figure out when they should be used in PHP... I have two questions: 1-How do you keep your objects? For example if we had a shopping cart, would we create a new shopping cart object and everytime the user adds/removes items update that same object? and how would you keep that object's information as the user browses through the site? Would you use serialize/unserialize session variable functions? or is there a better way? 2- For example, if we have a website that has users why would we want to make a "Users" class containing all the user information? Can't we just insert/retrieve data directly from the database? and when we get the data from the database what exactly is the point of creating an object out of them when we can just print it out? I guess my question is why would having a Users class be useful in a php web application? (assume users have name, username, password, address, etc.)
Using Two Classes
Lets say I have one class that deals with the database (class called SQL), a class that manages the user authentication (class called User) and another class that does something like getting all the options from the database for a poll (class called Options). The class Options is extended by another class called Poll which is extended by the class called Gateway, like this: class SQL {} class User {} class Gateway {} class Poll extends Gateway {} class Options extends Poll {} $sql = new SQL; $sql->connect(); $user = new User; $user->authenticate(); $poll = new Options; As you see, SQL and User are in no way connected to the other classes, however sometimes I'd like to use SQL inside the Options class. Would it be better to use global inside one of Options' function, like this: class Options { public function __construct() { global $sql; $sql->query(); } } ...or would it be better to let Gateway extend Users and SQL, like this: class SQL {} class User extends SQL {} class Gateway extends User {} class Poll extends Gateway {} class Options extends Poll {} // etc...
When To Use Classes
I've been developing websites using PHP for several years now, yet have never used OOP concepts. I am familiar with them, but have never had a need for them in my projects. However, I am now interested in using them to expand my knowledge, but unsure when they are really needed. Lets say I have a MySQL database with a "customer" table that stores all their information such as name, address, phone number, etc. The web page will do basic queries on the customer info, inserts, updates, selects, and so forth. I'm trying to incorporate classes with this, yet it seems like it's a lot more work than if I were simply using function to perform the actions on the database. I did some browsing on the web and it doesn't seem like classes are really needed when your dealing with data from a database (other than possible a class to connect to the db). Is this true? Any examples maybe?
How Can I Find A Name From One Table In A Text From Another Table?
I have one table with a description field and other info, and I also have another table with a list of names and picture url:s. When I display the text description on my site I'd like to know if there are a match with a name from the 'names' table in the text. Code:
Returning Table Name As Well As Fields From That Table
I am returning all fields from news and from regional, however I want to determine where the fields have come from when I ouput the data, therefore I need to return the table name with the fields. Is this possible? Code:
Problem With Classes..
Has anyone had problems with PHP returning two different results on different machines when using classes? Here's the scenario: On win2k/IIS/PHP 4.0.3, I set up a class like this: class myClass { var $thisVariable = "test"; function getVariable(){ $this->variable = $thisVariable; echo $this->variable } } When I instantiate it, it returns "test" but when I upload the file to my website server, which is Apache running PHP 4.0.2, it refuses to return anything.. but when I set it like this: class myClass { var $variable; function getVariable(){ $this->variable = "test"; echo $this->variable } } It works just fine. Any idea why?
Classes And Requires
I am wanting to include some common function into a class, these function are stored in include files, the thing is, PHP will not allow this, or i am doing something wrong. This is the code: PHP Code:
Storing Classes
Is it possible to store classes in an array? I am fairly new to PHP, and haven't found anything either way yet. I have a program that where you can have multiple notes attached to a ticket, which are stored in a database. I would like to just pull all the notes from the database, storing each one in a seperate class, which itself is stored in an array (well, another class, but it's a classList, it's mainly an array). I'm getting an error when I run the page: "Cannot use a scalar value as an array", and "Call to a member function on a non-object". The second is related to the first, as I'm calling a function on the array value. If it is possible, I probably coded something wrong. If that's the case, I'll post some code.
Classes In PHP - Question
//I've the class Application class Application... //I call show function from class Abstract ... $seller = new Seller... $seller->show(...) ... $customer = new Customer... $customer->show(...) //I've also the class Abstract - it implements some common code code for all classes Seller, Customer,... etc.. class Abstract... ... function show(...){ ... $form = new HTML_QuickForm... $this->List($form); } //here's Customer class - some special code for customer class customer extends Abstract function List($form){ $quickFormSelect = new HTML_QuickForm_select ... $form->addElement($quickFormSelect)); } of course, I can do it, using some "if's" i Abstract class, but the above code could simplify my application, unfortunately it doesn't work Any suggestions about this code? ps. the above code can looks like this: .... function Lista(){ ... $quickFormSelect = new HTML_QuickForm_select ... return $quickFormSelect; } //and then in Abstarct class $form->addElement($this->Lista()); but in this solution I can add only one $quickFormSelect do $form, how to add some more $quickFormSelect calling function List only one (like in my unfortunetly non working code - $this->List($form);)
One Must Use Globals In Ones Classes
I get the impression that most people who are using objects in their PHP projects are mixing them with procedural code. The design, I think, is one where the procedural code is the client code, and the classes are a library of utility code. As such, when I've asked about how to get globals into objects, I've been told that I should pass them in as the parameters to a method. Easy enough if you have some procedural code. This answer I've been given assumes that there is something outside of the object, some procedural code that can get hold of the global and then hand it to the object. However, am I wrong in saying that if you wanted to go pure OO, you'd have to grab the globals from inside of the objects? You could limit this to the constructor, and possibly you could limit to just a single master object that contained all other objects, but still, you'd have to do pull globals straight into the object, yes?
Extending Classes
I've created a database export class with extensions for exporting to csv, xls, html and xml. The file export.inc.php contains the 'export' class which deals with getting the data and storing the field names and row data in arrays - used for all exports. export_csv.inc.php include()s export.inc.php and contains 'export_csv' which extends the export class, formatting the field name and row arrays as a csv file and sending the file to the browser. There are other similar extensions for xls, html and xml. At the moment I have to do something like this to get my exported data: switch ($type) { case "csv": include("path/to/export_csv.inc.php"); $export = new export_csv(); break; case "xls": include("path/to/export_xls.inc.php"); $export = new export_xls(); break; ... } $export->get_data($dbhost,$dbname,$dbuser,$dbpass,$sql); $export->output(); That seems quite untidy and what I'd really like to do is this: include("path/to/export.inc.php"); $export = new export("csv"); $export->get_data($dbhost,$dbname,$dbuser,$dbpass,$sql); $export->output(); I know it must be possible because that's how ADODB selects its drivers, but I can't get my head round how it works. Any idea how I should go about organising my classes and their separate files? Has it got something to do with the 'factory method' that I've seen mentioned in a few places recently?
Friend Classes
Now that PHP5 has proper scoping for class properties and methods, I've been looking in vain for friend classes, or wondering if there's another way to achieve this effect: class A { protected var $v1; .... } class AHelper { .... function .... { .... $helper = new AHelper ( ... ); .... if ($helper->v1) ... } So A has a property which really is not supposed to be public, but AHelper (which does not inherit from A) has a special relationship with A and wants to be able to delve inside it. Note that just providing a public accessor won't help: it's logically the same as making the property public. C++ manages this by having 'friend classes' - classes which are allowed inside a class even though they are not derived from it. I suppose I could write a public accessor method which takes its caller as an argument and checks its type before it will go ahead and fetch the value; but that's inelegant, heavy, and only takes effect at run time. Has anybody got any better suggestions? [I see somebody asked the same question two weeks ago on faqts, but did not get an answer)
|