Jump to content


Photo

dynamic


  • Please log in to reply
21 replies to this topic

#1 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 06 July 2006 - 11:14 AM

is it possible to use php to create dynamic web pages

ex ;

if i create a table (let assume that i don't know the attributes) is it possible to print its content

kusal - sri lanka
www.kuppiya.com

#2 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 06 July 2006 - 11:26 AM

Check out the PEAR package for easely creating dynamic tables.
I'm sure you'll find what you'r looking for.

<a href="http://pear.php.net/.../HTML_Table</a>

#3 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 06 July 2006 - 12:12 PM

can any one help me with a code

(thank you for your help "CheesierAngel")
www.kuppiya.com

#4 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 06 July 2006 - 12:17 PM

kusal, what do you mean dynamic page ?
page=contact, page=news ? Try checking the FAQ, it's a sticky thread.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#5 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 06 July 2006 - 12:31 PM

thing is this, i'm developing a inventory control system for a company(as my 2nd year project) and they request that the system sould be able create tables when they needed, using php. then for more complication the tables will be later used to do functions like add, delete, update....(i think you got the point) but i don't have any idea what would be the attributes of those table bcos they enter those details.
so i need a codeing that will take out those attributes from what ever the table and do above mentioned functions


www.kuppiya.com

#6 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 06 July 2006 - 12:41 PM

There are some CMS's that have this kind of functions integrated as default.
For example cakePHP uses scaffolding... . For wathever table you created in your database
cakePHP will make the forms for adding, editing, deleting your table content automaticly.
The only work left is making the .thtml files for the look en feel of the forms.

Your can read more about this at <a href="http://manual.cakeph...g/chapter/5</a>

#7 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 06 July 2006 - 12:52 PM

i can't use 3rd party libaries (it's a project)
pure php
www.kuppiya.com

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 12:55 PM

so...what is your question - can you do it with php? well since that's your project assignment, then obviously you should know that you can do that in php.  do you have a specific question? do you know anything about php? if not, you are going to have to start with your first hello world example just like with any other language.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#9 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 06 July 2006 - 01:04 PM

yes i know bit of php, i have almost finished my project, but only for the predefiened tables, i don't know a way to get information from tables that i don't know (tables that would be created by the company)
(MAN IT'S VERY HARD EXPRESS MY MESSAGE).

kusal
www.kuppiya.com

#10 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 01:14 PM

maybe it would help if you gave an example.  are you talking about dynamically creating database tables through php? if so, then this is not really a php question, but a database (example: mysql) question.  You would use the same commands (for example) for creating a table as you would in your database. As far as php, you'd just use the variable name instead of an actual name. 

example using mysql:
<?php
   $tablename = $_POST['tablename']; //name of table user entered from some form
   $columnname = $_POST['columnname']; //name of some column user entered from some form

//example: create the table with one column that's varchar(30) type, default not null
$sql = "CREATE TABLE $tablename ($columnname varchar(30) NOT NULL)";
$result = mysql_query($sql);

?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#11 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 06 July 2006 - 01:19 PM

Search for sql functions to discover how your tables and which tables are build in your database.
MySQL has his own functions for determining which tables there were defined in your database, which columnheaders they have, the kind of data stored in the different columns and so on.

You better first check out the MySQL functions you can execute from your php script to receive the needed data.
With this data you can recreate your tables dynamicly with php.

For example:
query "show tables" and store it into a var.
foreach(var -> table)
    query desc table
    recreate the table
    query for all content in the table
    output your data

It is for your project so i'll let you write the code yourself, but i want to give you the 'thinking' solution. (Which is for most cases the most difficult part)

#12 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 06 July 2006 - 01:29 PM

Yes you got the point(but not fully).

yes i know that in that way i can create tables,

let assume that the above created table needed to insert data (assume that i have given the system to them)then i need to have created a page to add those details in the newly created table.

but the problem is, i don't know any details about that table attribute, how can i dynamicaly get those table details to create a adding page
www.kuppiya.com

#13 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 01:49 PM

I still don't understand what you are asking.  If you have input fields for the user to input a table name, column name and column type, you would create the table based off of the inputed information.  Are you now asking something like this: User wants to go to a page and there will be a list of the tables he just created, and it lists what type of column it is, so he knows what kind of info he can put in it?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#14 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 06 July 2006 - 02:01 PM

Can you give a specific example for what it should be used for ?
Do you already have some code we can see ?

#15 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 02:08 PM

assuming that you are asking what i mentioned in my previous post - again, this is not really a php question. but here is an example of the sql query and how you would utilize it with php:

<?php
//obviously you need to connect to the db first. this also 
//assumes you are using mysql, seeing as you have yet
//to mention what db you are using...

$tablename = 'nameoftable'; //put name of table here

//this query string will return a list of all the columns in the
//table and the information about the columns
$sql = "show columns from $tablename";
$result = mysql_query($sql) or die(mysql_error());

//fetch and make an array of the results of the query
while ($rs = mysql_fetch_array($result, MYSQL_ASSOC)) {
   $list[] = $rs;
}

//example of listing out the results:
foreach ($list as $row) {
   echo "<b>-- {$row['Field']} -- </b><br>";
   foreach ($row as $key => $val) { 
      echo "$key : $val <br>";
   }
}
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#16 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 06 July 2006 - 02:09 PM

He means have something to where tables can auto-generate themselves using php with proper attributes based on the situation.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#17 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 02:10 PM

well i gave him an example of that and he said that's not quite what he meant.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#18 kusal

kusal
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationSri Lanka - Colobmo

Posted 07 July 2006 - 06:42 AM

the problem is not how to create a table or retrieving data from it.

ex:

the project is that i create an invetory control system for computer hardware devices for a mobile telephone company in sri lanka. the company has pc,routers,servers,laptops,printer,telephones.....etc,  to be stock controlled. so i have created tables for every device with there uniqe attributes. and created funtions like add,delete,update,view...etc, for every table using php and mysql

NOW THE PROBLEM IS THAT COMPANY IS ASKING ME TO CREATE A FUNCTION THAT, IF THEY COME ACROSS NEW HARDWARE DEVICE (EX: ISP LOAD BALANCER, WHICH IS NOT CREATED ABOVE) THEY NEED TO CREATE A TABLE FOR IT AND NEED TO HAVE ALL ABOVE MENTIONED FUNCTIONS.

HOW CAN I DO THIS, I NEED TO CREATE HTML PAGES AND PHP PAGES DYNAMICLY FOR A CHANGING DATABASE.
www.kuppiya.com

#19 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 07 July 2006 - 06:48 AM

Please don't use capital letters, it doesn't sound nice to me :(
Bold those words would be better if you want people to take note of that parts.

Hmm.. You could store the informations in database, then loop them out.
Take a look at this page, you can store all those items then loop them out,
hope I got what you mean.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#20 Mr.x

Mr.x
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 07 July 2006 - 06:57 AM

I had to do something similar for a cell phone store, except it was with manufacturers of the phones.

One of the best tips I got was to create a seperate table just for differn't categories or product types.

Ie in the table would just be
Servers
Desks
Monitors
Phones etc.

I then would while loop all of these out and it created a list of items for them to choose...

So say they choose servers, it would go to details.php?type=servers for example.

Before hand you have to figure out some of the things they have in common, so are you getting into specific detail with each object or not? If not then you can do statics of such things like quantity, location, year purchased, etc.

Then the script loops through your database and outputs out any "items" that are categorized as a server to a new row in your table, then you have standard functions such as add or subtract them.

Then later on you make an admin panel so if they add in SUPER SERVERS then all it does is create the new category and they have the option to add products as Super Servers.


Not sure if this helps, if it doesn't help hopefully it will help you solve some questions.

-Sean




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users