Create Table From Variable
I need to know, how I can to do to create a table in PHP, taking de
name for this table from a form variable.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Loop Through Array And Create Variable Session Variable Names
As part of my user authentication class I've written a method that sets session variables. I pass an array to the function by reference which contains elements populated with information from the users table in the DB (name, street, country etc) At the moment the function looks like this: /* Set the session variables for easy access to user data */ function _setSessionData(&$userData) { $_SESSION['loggedOn'] = true; // Logged on $_SESSION['userID'] = $userData['UserID']; $_SESSION['username'] = $userData['UserName']; $_SESSION['password'] = $userData['Password']; $_SESSION['firstName'] = $userData['FirstName']; $_SESSION['surname'] = $userData['Surname']; $_SESSION['email'] = $userData['Email']; $_SESSION['street'] = $userData['Street']; $_SESSION['city'] = $userData['City']; return true; } What I'm wondering is if it is possible to loop through the $userData array, and dynamically name and populate the session variables rather than listing them all and assigning like I have?
Create DB Table
how to create a table in a SQL database using PHP3. I can login via telnet and create a table but that is sorta worthless considering that I'd like to be able to do it via a browser instead. Would someone please post some quick code to point me in the right direction?
SQL Create Table From Pdf
I would like to use a routine which has as input a pdf form file and returns the SQL statement to create the table for a SQL database. Did someone know such a tool?
CREATE Table With PHP Script
I'm trying to write a PHP script that will create tables, so I'm working of a test script at the moment and I've been trying to use some code from a phpBB script to do this as while mysql has a nice mysql_create_db function they have no create_table function, not that I can find anyway. I can't find a similar problem from searching here either :-( The code I'm using is below... <?php include ("../cgi-bin/connect.inc"); $tables = array ("test" => "CREATE TABLE test ( testing varchar(20), )"); $result = mysql_query($tables); if ($result) {echo "YEY";} else { echo("<P>Error: " . mysql_error() . "</P>"); exit(); } ?> and it returns this... Error: You have an error in your SQL syntax near 'Array' at line 1 Something simpler such as <?php include ("../cgi-bin/connect.inc"); CREATE TABLE test ( country varchar(40) NOT NULL, UNIQUE country (country) ); ?> just gives an error on the 3rd line If anyone can point me in the right direction as to how to create tables with PHP scripts, which I know must be possible as phpBB manages fine.
MySQL Table Create
Here is the code I'm trying to create the database with (I'm using phpMyAdmin so I just select the file I want to use and press submit and it creates the tables). CREATE TABLE bips ( banned_ip varchar(15) NOT NULL); CREATE TABLE messages ( entry_id double(16,4) DEFAULT Ɔ.0000' NOT NULL auto_increment, name varchar(25) NOT NULL, email varchar(35) NOT NULL, icq int(11) NOT NULL, http varchar(50) NOT NULL, message mediumtext NOT NULL, when int(12) NOT NULL, ip varchar(15) NOT NULL, UNIQUE entry_id (entry_id), PRIMARY KEY (entry_id)); ------------------------ phpMyAdmin gives me an error with that, (none of those tables exists btw)... the error is MySQL said: You have an error in your SQL syntax near 'when int(12) NOT NULL, ip varchar(15) NOT NULL, UNIQUE entry_id (entry_i' at line 8 .
CREATE TABLE Problem
I have a problem creating mySQL tables with PHP. I am making an app where a user can create a project. Pressing "submit" on proj_form.php goes to proj_add.php where a couple of things happen. The project's meta information is put into a project table, mysql_insert_id() gets the $proj_ID, and a table named that $proj_ID is created to hold all of that project's tasks. Here is my code to create the table for a project's tasks: // 2) Create a table for the tasks of the new project $sql = "CREATE TABLE $proj_ID ( task_ID int unsigned NOT NULL auto_increment, task varchar(40), person varchar(10), notes varchar(255), PRIMARY KEY (`task_ID`))"; Here is the error message that creates: You have an error in your SQL syntax near ' ( task_ID int unsigned NOT NULL auto_increment, task' at line 1 It has to do with trying to create a table named $proj_ID. How do I get that to work?
Create Mysql Table
I'm trying to create a mysql table in php. i have no problems doing a select, insert or anything else. i just don't know what the proper code is to create a table if it even exists.
Create & Populate Table?
I am trying to do two things with one form: 1. Create a table in a MySQL database 2. Populate it at the same time So far I have been able to create it, but the population isn't going so well. Here is the basic code I am using. PHP Code:
Create A One Column Table
Using the following code, how do I create a one column table, with "Firstname, Lastname & Sex" as the heading. Also, how do I display the row data (i.e Firstname etc) using the following format?: Code:
Create Html Table With Php Result?
I'm looking to display 5 records in one rows, from the database. What i mean is, basically, let's take the "emails" as an example. I have a table with 100s of email addresses. Now i want to display these email addresses on a html table, but i want to display only 5 email adresses per table row, then the next 5 in the next table row and so on.
Create A Table Regarding A Text File
I have this .txt file : Roger|tow25$rank259 Isabelle|tow36$rank24 Pascal|tow12$rank29 Sergeï|tow45$rank5 Michel|tow1245$rank45478 Frédéric|tow1$rank125425 And this programm php3 <?php $fichier = "classeur.txt"; if($fp = fopen($fichier,"r")){ $ligne=1; echo "<table border=1 bordercolor="#00CCFF" width=500> "; echo "<tr align=center><td colspan=3>TITRE</td>"; while (!feof($fp)) { list( $name, $tampon ) = explode( "|tow", $fp ); list( $tow, $obj ) = explode ( "$rank", $tampon ); echo " <tr>"; echo "<td align=center><b>Nom".$name."</b></td><td>Tow".$tow."</td><td>Obj".$obj."</td[color=blue] >";[/color] echo "</tr> "; $ligne++; echo "</table> "; echo "$cell"; fclose($fp); }else{ echo "Error : open impossible ".$fichier; exit(); } ?> I would like to past each value of the lines in the tex file, in 3 variables $nom; $tow; $obj and create a table with 3 column ( column 1 the name, in 2 the tow, and in 3 the obj)
Editor To Create Table From MySQL
Does anyone know of a Windows editor I can use to design a table from a MySQL database? I have a end-user catalog I need to create. Nothing fancy - just display a few fields. I could hand code it, but do not have the time to relearn all the sql. No shopping-cart or anthing, just display fields.
Urgent: Create Table If It Doesn't Exist?
I'm using a script what inserts data into a table (called "_$this" - e.g. "_2") like the following: Code: mysql_query("insert into _$this->uid (time,referer) values ('".time()."','$this->referer2'"); I need to check if the table "_$this" exists before inserting data and if it doesn't exist i'd like to create this table before inserting it like: Code: mysql_query("CREATE TABLE _$this (definitions)"); Means in simple steps: 1. Check if table exists - if yes -> step 3, if no -> step 2 2. Create table -> step 3 3. Insert data Any code snippet for a php-newbie like me?
Row Size Error On Create Of Table
I have a table that already exists in MySQL, and I want to add it to another database - but this time defined with the UTF-8 charset. This is part of some preparation to move from the default lation1 to utf8. I have exported my existing table to a .sql file and changed the latin1 reference to utf8. But when I run the SQL script to create the table in my other database it generates a row size error. Code:
Create A Dynamic Table Javascript?
I have picture section where users can upload pictures to my website and I have created a basic way viewing these pictures but this is not astheticaly pleasing. So i was wondering if i could populate a html table with these pictures. The way this system works is that it uses a while loop that brings the date, url and also who uploaded the picture into the page. I was wondering if this information could be put into a table but i cannot see a way. Code:
Dynamically Create Table Rows As Needed
I have a form with a table. Each table row has a ID= "some number". I have 4 rows and might need to create more. how can i do this in php? To go along with this, When I hit the submit buton, I then need all the table row data saved to a db i have. I can insert 1 line with out a issue. I also made sure the table row name="" fields are unique. ex. Code:
Create A Link In A Table From Echo 'ed Sql Data
im using the following code to output everything in a database table under headings in an html table untill theres no more data left. The headings are things like name address etc. could i make it so when all the data is shown each name or ID becomes a link and when clicked takes the user to a more detailed page on the selected client. because of the way the table is generated there is no where to place link tags. is there a more appropriate way that is more editable? it would be nice to have checkboxes at the edge of each customer also to enable a complete status or deleting a client from the table. Code:
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?
Create A Variable Of A Stringname
How can I do this: 1) i have string $test="jeroen"; 2) a want to create $jeroen = 0; how can i do this? $'$test' = 0 ; ? (i don't think this wil work this is code where i need this: $fotoarray[0]="bedrijfsleiderfoto"; $fotoarray[1]="logo"; $fotoarray[2]="foto1"; $fotoarray[3]="foto2"; $fotoarray[4]="foto3"; $fotoarray[5]="foto4"; for($i=0;$i<6;$i++) { if (isset($'$fotoarray[$i]')) upload($'$fotoarray[$i]',$naam,$fotoarray[$i]); }
Create Listbox Depending On Variable
I currently have a variable called $NumPlayers which contains a number between 4 and 8; depending on this value; i would like to create this amount of listboxes on my page. For example if the value of $NumPlayers is 6; I would like 6 listboxes to be displayed on the page with names such as "Lstbox1" "Lstbox2". I'm a bit clueless where to start; and was hoping someone could point me in the right direction.
How To Create A Hidden Field Variable From An Echoed PHP Figure?
I have a PHP script on a shopping cart summary page that creates an invoice number and then echoes it to the page. This page, when submitted, will go to the shopping cart processor. The echo portion of the script is working properly, it generates the number as intended. My problem is that, not being very experienced in PHP, I want the invoice number not only echoed (which it is doing properly now), but also to populate a value in a hidden field that is submitted to the shopping cart processing page. My question is how do I populate the hidden field with the figure that is now being echoed in the script below? The script that generates and echoes the invoice number is as follows: <?php echo "SA"; //department code echo date ("mdy"); //date generator // begin counter this reads figure from "count_file.txt" if (file_exists('count_file.txt')) { $fil = fopen('count_file.txt', r); $dat = fread($fil, filesize('count_file.txt')); echo $dat+1; fclose($fil); $fil = fopen('count_file.txt', w); fwrite($fil, $dat+1); } else { $fil = fopen('count_file.txt', w); fwrite($fil, 1); echo Ƈ' fclose($fil); } // end counter ?> The hidden field is as follows: <input name="Invoice_Num" type="hidden" id="Invoice_Num" value=" "> I would like the value in the above to reflect the invoice number that is echoed by the above PHP script.
Variable Table Name
I'm having some trouble doing a table update through my form. I have done it ok dozens of times before, but the only difference now is that the $tablename is variable. $tablename is being passed through the URL. i can echo it fine and everything, but the form just won't update the records. PHP Code:
Put A Html Table In A Variable
I want to do the following: I want to draw a table in html (with the echo command) and put that in a variable so I can draw that table via that variable. I got the following (large table ;-) Code:
Dumping A Table Into A Variable.
I am trying to dump my entire user table into a variable so I can go through them with foreach so for example I want do something like this. $result = mysql(query for user data); foreach($result as $users){ echo $users['user'];} and so forth any idea guys?
New Table Created From Variable
Is it possible to create a table in a mysql database using a variable that originated from a form? I've searched the net for some info on this, but have had no success. Basically I want an admin to be able to set up a weekly round of football, and have a new table created for that round, based on teams set up each week using a form. The admin would enter the round number, and that would be the name of the new table. The teams listed in the form would simply be posted in the table after it is created with a game ID. So far, I only know how to create a table by running a sql query, but the admin won't know how to do that, I'd rather if it could be done using a form.
Set Variable Name Use Field Name From Table
I have a query string that sets the value of Variables below: if ($DB == "Departments") { $tracking_id = $data22['tracking_id']; $dept_name = $data22['dept_name'];} simple and straight forward. Now I would like to set a loop that would set the variable name and value based on the field names in the table queried. if ($DB == "Departments") { $querystring = "Select * from ".$DB; $result=mysql_query($querystring); while(($field = mysql_fetch_field($result))) { $field->name = $data22[$field->name];}} can I set the variable name using the $field->name if so how? I have tried this code with no luck and no luck searching. This is a small example. I have queries with fifteen plus fields. This would also remove the need to modify this code if a field needs to be added to the table. And yes I have had to add fields to the tables.
How To Show Table Based On Variable?
I want to display a table on a page based on whether a button is pressed or not. I'm new at php so I'm sure I'm making a basic mistake. Here's what I am trying. My thought was that $show_summary would switch states with each click but it is coming up always true. So I'm guessing that is the default setting when the page loads. Can someone please point out where I am going wrong? if(isset($_POST['summary'])) { $show_summary = true; } else { $show_summary = false; } <FORM method="POST" action="testpage.php"> <INPUT type="submit" name="summary" value="Show Summary"> </FORM> <?php if ($show_summary == true) { ?> <table border="1" cellpadding="3"> <tr> <td class="smallText" align="center" width="80%"><?php echo "URL"; ?></td> </tr> </table> <?php } ?>
Variable Data In Dynamic Table.
What I'm trying to do is list the values of an array into different table rows while alternating the color of the table rows. Simple enough right? It makes the table fine. Creates the proper ammount of rows. It even alternates color (yay!). The only thing that it doesn't do is list the values in the array. PHP Code:
Return MySQL Table Name As PHP Variable
I've got a MySQL query something like the following: $fields = mysql_query('SELECT ItemID FROM Table1 UNION SELECT ItemID FROM Table2 ORDER BY RAND() LIMIT 1'); There's more criteria than that, but this illustrates the basics of the situation. Essentially I want to randomly select one row from either of the two tables. I've got that part down; the query is returning the results I need. However, the problem I'm having is finding out which table the query pulled the result from. I'm querying two tables and will return one result - but I need to know which table the result came from. Is there any way to assign it to a variable? If so, how can it be done?
Data From Table Based On Variable
Im making a website where users sign up to a club each user has a user_id and each club has a club_id. On the first page after logging in I want to be able to include a standard welcome message which will say something like "Welcome to $clubname". Then once the admin signs in he then has the ability to edit the post and write some information on the club and save it. However within the website there are lots of different clubs so I need the message that applies to a particular club to only be visible if the user is linked to the club. My database has 3 tables, 1 for users, 1 for clubs and 1 for welcome.
Not Echoing A Variable If It Exists In A MySQL Table
I have a variable $mydate which loops for all the days of a month (in a while loop), so therefore for April its: 01042007 02042007 03042007, etc... I also have a MySQL table "bookings", which contains the field "date". This field is populated with rows of dates, with the same format as those in $mydate (eg. 01042007) Is there any way to not echo $mydate if it exists as one of the entries in the "date" field in the database?
Insert Empy Variable Into Mysql Table
I've got a form in which a couple of the address fields can be empty when the form is submitted... I haven't actually managed to get the Insert statement to work yet (see other post..), but I know this seems to also be causing problems. I have set up the table fields for these 2 address form fields to be Yes under the NULL column, but it still gives the almighty: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , London, W1, UK, 9991, 007, 'warstormer@hotmail.com'' at line 1 Code:
Correct Syntax For Table Variable Names Containing A Space
What is the correct syntax to use when inserting a value into a table that contains a variable name with spaces. This works $query = "INSERT INTO Catalogue (Author) VALUES ('Stephen King')" And this does not $query = "INSERT INTO Catalogue (Book title) VALUES ('The Crow')"
Retrieve Data From Table With Multiple Returned Variable
I am trying to set up a function to recalculate prices for my products - (per product that is) The problem I am having is that I have a table that stores the prices for each client type (so one product can have multiple prices) so I need to be able to recalculate the price for each client. Code:
Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before, but I haven't seen many good examples of this. Of course Pear::DB probably uses this code in some of its API, probably in dealing with auto-increment indexes and prepared statements. Maybe I'm off base here, but I'm looking for something like this: (psuedo-code) Of course the seq table only needs 1 row holding id, which is updated. select id from tbl; // get result resouce and do fetch, store value in $myid set @myvar = $myid + 1; // can php send to MySQL with a query? ( never seen this ) update myseq set id=@myvar // send this statement through in a update/query // for use in PHP code $newSeqVal = $myid +1
Create A Sequence In MySQL, With Mysql Variable?
This might be fairly easy to do and I think I've seen the code before, but I haven't seen many good examples of this. Of course Pear::DB probably uses this code in some of its API, probably in dealing with auto-increment indexes and prepared statements. Maybe I'm off base here, but I'm looking for something like this: (psuedo-code) Of course the seq table only needs 1 row holding id, which is updated. select id from tbl; // get result resouce and do fetch, store value in $myid set @myvar = $myid + 1; // can php send to MySQL with a query? ( never seen this ) update myseq set id=@myvar // send this statement through in a update/query // for use in PHP code $newSeqVal = $myid +1
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:
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?
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....
|