PHP - Wordpress - Is There A Way To Setup A Crud System For My Database?
I've played around with CakePHP, then XCrud (a decent CRUD application) but I gave up on both of them, XCrud was great for everything up until it came to managing complicated relational database tables. Anyhow, I'm using wordpress a lot now cuz it lets me stop reinventing the wheel so much and although I was able to integrate XCrud into WordPress as a plugin, I think the best way to go is just transfer my database tables to WordPress tables and display them as custom post types. My time is really limited right now though, is there a plugin/set of plugins I can use to automate the process? To show you what I mean, heres the XCrud list display of one of the tables:
thats great because it automatically sets up the CRUD thing and lets you add and edit fields to the table, and doesn't heavily box you into their system but I have a table of plants, one for products, one for pharmacology, one for categories which are all related to each other, and some of them are structured in a tree/nested hierarchy structure so long story short, I need to do advanced searches based on these relations and handle these tree structured tables and CakePHP didn't work out, and XCrud has crappy documentation and isn't popular enough to find good info.
So how would you go about transfering this system to WordPress? I'm guessing I need to make custom post types for each table but what I don't yet know is how to transfer the DB tables to WordPress format, how to handle the relationships between each table and how to handle the hierarchical tree structures.
Similar TutorialsHi
I just finished this tutorial('http://www.startutor...torial-part-3/)
and everything was working fine until I decided to add last names to the application.
I got everything working on all the other pages except the Update page.
This is my php code.
Hello I need a great help for my problem, I tried to insert multiple checkboxs for "$_POST active" in my CRUD and the values must be saved in the database but will be saved as "Array" everytime. foreach($_POST['active'] as $act){//query? } Here the PHP code <?php require_once "../lakota/config.php"; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['faction'], $_POST['stations'], $_POST["active"], $_POST['pending'], $_POST['influence'], $_POST['id_fact'])) { if(isset($_POST["submit"])){ $activearr=$_POST["active"]; $newvalues= implode(",", $activearr); include_once "../lakota/checkboxClass.php"; $checkBoxClass=new checkboxClass(); echo $checkBoxClass->addtoDatabase($newvalues); } $sql = "INSERT INTO lakotabgs (faction, stations, active, pending, influence, id_fact) VALUES (?,?,?,?,?,?)"; if ($stmt = $link->prepare($sql)) { $stmt->bind_param("ssssss", $_POST['faction'], $_POST['stations'], $_POST["active"], $_POST['pending'], $_POST['influence'], $_POST['id_fact']); if ($stmt->execute()) { header("location: ../lakota/index.php"); exit(); } else { echo "Error! Try again later."; } $stmt->close(); } } $link->close(); } ?> HTML code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Add new info</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head> <body> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <label><b>Active States</b></label> <input name="active[]" class="form-control" id="example1" type="checkbox" value="None" /> <label for="example1">None</label> <input name="active[]" class="form-control" id="example2" type="checkbox" value="Everybody" /> <label for="example2">Everybody</label> <input name="active[]" class="form-control" id="example3" type="checkbox" value="Unknown" /> <label for="example3">Unknown</label> <input type="submit" id="submit" name="submit" class="btn btn-primary" value="Add new info"> <a href="../lakota/index.php" class="btn btn-default">Back</a> </form> </body> </html> Edited November 14, 2020 by AccuCORE hello everyone, I am about to start coding my pages to display results from a database but before i do i want to know information about the following : Is it best to upload images to a database?and display them accordingly? or is it best to use images from a directory? What is most commonly used and or more reliable? Another topic i have trouble finding information on is actually positioning the output from you mysql database, is this practice done with tables?fields and rows? What is this method called? And is there more then one way to go about controlling result layout on your page? Sorry about the 1001 questions , but i am unable to find a clear answer on the topic ..especially question two . Thanks in advance. Hey everyone, I'm creating a website which requires users to login. I didn't want to have to do my own crypto, so I basically created it with Wordpress. I'm at the point where I don't want to use Wordpress for the whole site--just the login system. So I was wondering how I can piggyback off the user management system of Wordpress while using my own script for the rest of the site. I know that Wordpress ends up storing passwords in the database as HMACs, for what that's worth. Thank you, Ryan Working on a website directory that includes ratings for listed companies. Trying to obtain information from database that would put some companies in a higher category than others. Or at least, I believe that is the approach I should be taking.
There are a few tricky issues.
1. Ratings are their own custom posts but are attached to company pages (parents)
2. Rating values I need to obtain are meta keys (1. total number of ratings & 2. rating average of EACH)
3. Ratings are based on four criteria which are summed and averaged for each rating submitted. As a result, values are rarely single digits such as 4 or 5 but include decimals rounded to 1 place (e.g. 4.8 or 3.5)
Additional info:
Ratings are based on 5-star system (out of 5)
Higher category would be business that achieved at least 10 ratings of 4 or more
Any help appreciated.
Have a client who has a Wordpress site that is running slowly and wants performance improved. It is averaging on the order of 7 seconds or so to render basic pages. No video, few images, etc. The database has about 1 million records. my primary question is, "When does Wordpress hit a point that the db is too large and will slow down a site?" i understand there is no definitive answer, just trying to get a ballpark. its noteworthy that about 700,000 of those records are in a table for the REDIRECTION plugin. ive deactivated that plugin to eliminate those records as a factor.
as an fyi to anyone with any other ideas on how to speed the site up
- ive deactivated all plugins with no effect
- activated Twentyfourteen theme with no improvement ( to eliminate theme issues )
- uploaded a php page outside of Wordpress and it rendered immediately.
I'm looking to open a custom giftcard shop in which I'll be selling giftcards at 75%-95% of the face value. (I usually buy them off ebay cheap and resell them). I've already got the login system complete by using one I found online. What I'm looking to do now is make the shop section now where I can import a text document with the giftcard #, and Pin number to have them all show up in a list (but have only the first 6 numbers show up and the rest stared out with "***" until purchased, with the option to add each individual one to the cart (checkboxes beside each one). But I want them to be able to buy them with "credits". Credits being a site currency I'd like to be created. I want users to be able to buy these "credits" with the LibertyReserve API. These credits are to be attached to their login until used up. 1 credit = 1$ LR I notice Libertyreserve has a sample shop script: http://www.libertyreserve.com/en/home/downloads , but it doesnt exactly have the credit features and cart features I stated above, however I'm sure can be somewhat useful in coding what I need. Any help would be greatly appreciated, since I have no idea where to start. I'm sure this is basic to some, and well I'm looking to hire someone if they are confident they can complete this quick, otherwise any free feedback would help so much. Here is the site so far... http://www.eliteids.com/lrstore I have a database table of plants, one of chemicals, one of products, one of illnesses. Each table is connected, for example lets say opium poppies. They contain the chemical morphine. Morphine is used in painkiller products. Its used to treat pain and other illnesses. On the opium poppy page, I want to list all the chemicals found in the poppy. All the products (i.e. opium, laudanum) made from the poppy. All the illnesses which are treated with the poppy. Users need to be able to edit this page, and enter chemicals, products or illnesses that are related to this plant. They also need to be able to edit the info on the page.
Making database relations is a pain in the ass with CakePHP. I don't want to waste any more time so I'm thinking maybe making it as a wordpress plugin is the way to go. How would you go about this? Is there an easier way than wordpress, like a better CMS, or framework? If I use wordpress, should I do all the DB interactions with AJAX to avoid having to interact with the DB through wordpress (this gave me massive trouble in the past since I had my data in an external db)?
Hello, I am making a small CMS and I having some trouble with making a dynamic menu. I am wondering for a few days how I should make this menu system. I have the follow MySQL table: Code: [Select] CREATE TABLE `pages` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `time` varchar(10) DEFAULT NULL, `lastby` varchar(2) DEFAULT NULL, `order_id` varchar(2) DEFAULT NULL, `text` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB; Now I would like to have a menu system as following that I make menu's in a menu table with a name and a menu ID and that I could place those pages as parent or as subparent. How could I manage to turn my theory into reality? Ok, first off, I tested my own coded reg system and when I make an error test, the error shows but the user info gets added to the database. How can I stop letting the code add the user to the database when an error occurs. <?php include "lang.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PokePals - Registering</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js" /> <link rel="stylesheet" type="text/css" href="style.css" /></head> <body> <?php include "navbar.php"; ?> <?php // Important stuff goes here include "sql_local.php"; include "ban.php"; // Now for the registration page echo "<div class='panel'>"; if (isset($_POST["submit"])) { // Define the variables here $user = mysql_real_escape_string ($_POST["user"]); $pass1 = mysql_real_escape_string ($_POST["pass"]); $pass2 = mysql_real_escape_string ($_POST["passconf"]); $email = mysql_real_escape_string ($_POST["email"]); $email2 = mysql_real_escape_string ($_POST["email2"]); $dpfc = mysql_real_escape_string ($_POST["dpfc"]); $platinumfc = mysql_real_escape_string ($_POST["platinumfc"]); $hgssfc = mysql_real_escape_string ($_POST["hgssfc"]); $otherfc = mysql_real_escape_string ($_POST["otherfc"]); $favoritepkmn = mysql_real_escape_string ($_POST["favoritepkmn"]); $aboutme = mysql_real_escape_string ($_POST["aboutme"]); $hobbies = mysql_real_escape_string ($_POST["hobbies"]); $favorites = mysql_real_escape_string ($_POST["favorites"]); $gender = mysql_real_escape_string ($_POST["gender"]); // Now check for some errors // Did he/she fill out the form completely? Lets find out function errors() { if (!$_POST["user"] | !$_POST["pass"] | !$_POST["email"] ) { echo "<div class='error'>Please fill in the required fields</div>"; } // Passwords match if ($_POST['pass'] != $_POST['passconf']) { echo "<div class='error'>Password does not match with the other one</div>"; } // Email match if ($_POST['email'] != $_POST['email2']) { echo "<div class='error'>Email does not match with the other one</div>"; } } // Is the user banned? foreach($banned_ips as $ip_ban) { if($user_ip == $ip_ban) { die ("<div class='error'>Your IP address is banned from registering. Contact the site administrator for more info</div>"); } } // If there are no errors, start adding the information to the database if (!errors()) { // Secure the passwords $securepass = md5($pass1); // Submit to the database $insertuser = "INSERT INTO users (user, password, email, dpfc, platinumfc, hgssfc, otherfc, favoritepkmn, aboutme, hobbies, favorites, gender, regip) values ('$user', '$securepass', '$email', '$dpfc', '$platinumfc', '$hgssfc', '$otherfc', '$favoritepkmn', '$aboutme', '$hobbies', '$favorites', '$gender', '$user_ip')"; $add = mysql_query($insertuser, $con) or die ('Error: ' . mysql_error() . ' Please contact an admin'); if ($add) { echo ("<h3>Registration Success</h3><p>You may now login using your username and password. Start hatching some eggs now!</p>"); } } } ?> <div class='registerform'><form action='register.php' method='post'> <label>Username *</label> <input type='text' name='user' class='form1' value='<?php echo @$_POST['user']; ?>' /> <fieldset><legend>Password</legend> <label>Enter your password *</label> <input type='password' name='pass' class='form1' value='<?php echo @$_POST['pass']; ?>' /> <label>Password again *</label> <input type='password' name='passconf' class='form1' value='<?php echo @$_POST['passconf']; ?>' /> </fieldset> <fieldset><legend>Email</legend> <label>Enter your email *</label> <input type="text" name="email" class="form1" value="<?php echo @$_POST['email']; ?>" /> <label>Enter email again *</label> <input type="text" name="email2" class="form1" value="<?php echo @$_POST['email2']; ?>" /> </fieldset> <input type="submit" name="submit" class="submitbutton" value="Register!" /> </form> So I have to add data into my database for Olympic records for a school project. I have the sql statements and everything, but it will only enter the athlete's name and country into the table. My code is Code: [Select] <html> <head> <title> CSS </title> <style type="text/css"> p {font-family:arial; font-size:10pt;} body {margin: 0; padding: 0; text-align: center;} a:link {text-decoration: none} a:visited {text-decoration: overline; color:purple;} a:active {text-decoration: underline;} a:hover {text-decoration: line-through ; color:pink} input:hover {background: aqua; color:black} input:active { background: lime ; color: black; } input:focus { background: yellow; color: black; } .button {border: 1px dotted ; background:red; padding: 2px;} .button:hover {border: 2px dotted;background: url('submitbackground.jpg') no-repeat top left; } #main {margin: 0 auto; text-align: left; width: 800px;} #nav {clear: both; border: 1px solid; background-color:lightgreen; padding: 10px; width:auto; height: 8%;} #div1 {border: 1px solid; background-color:lightblue; padding: 10px; float: left; width:20%; height:92%;} #div2 {border: 1px solid; background-image: url('monkey.jpg'); background-repeat:no-repeat; background-position:center bottom ; padding: 10px; float:left; width:74.5%; height:92%;} </style> </head> <body> <?php session_start () ; print_r ($_REQUEST) ; if ($_SESSION['admin'] == 2) { echo " sorry" ; } else { echo $_SESSION['admin']; if(isset($_POST['athname'])){ $athname= $_POST['athname'] ; } if(isset($_POST['country'])){ $country = $_POST['country']; } if(isset($_POST['medal'])){ $medal= $_POST ['medal']; } if(isset($_POST['venueyear'])){ $venueyear= $_POST ['venueyear']; } if(isset($_POST['venuecity'])){ $venuecity= $_POST ['venuecity']; } if(isset($_POST['venuecountry'])){ $venuecountry= $_POST ['venuecountry']; } if(isset($_POST['event'])){ $event= $_POST ['event']; } if(isset($_POST['gender'])){ $gender= $_POST ['gender']; } echo "<div id='main'> " ; echo"<div id='nav'>"; echo"</div>" ; echo "<div id='div1'>" ; echo "<a href='index.php'>home</a><br/>" ; echo "<a href='search.php'>Search</a><br/>" ; echo "<a href='add-data.php'>Add Data</a><br/>" ; echo "<a href='DeleteData.php'>Delete Data</a>" ; echo "</div>" ; echo"<div id='div2'>" ; if (isset($_POST['search'])) { $connection = odbc_connect('Olympics', '', ''); if (!$connection) {exit("Conection Failed: " . $connection);} $enrID = null ; if ( $event == '100 meters' and $gender == 'M') { $enrID = 1 ; echo "$enrID" ; }elseif ($event == '200 meters' and $gender == 'M') { $enrID = 2 ; echo "$enrID" ; }elseif ($event == '400 meters'and $gender == 'M') { $enrID = 3 ; }elseif ($event == '800 meters' and $gender == 'M') { $enrID = 4 ; }elseif ($event == '1500 meters' and $gender == 'M') { $enrID = 5 ; }elseif ($event == 'Long Jump' and $gender == 'M') { $enrID = 6 ; }elseif ($event == 'High Jump' and $gender == 'M') { $enrID = 7 ; }elseif ($event == 'Shot put' and $gender == 'M') { $enrID = 8 ; }elseif ($event == 'basketball' and $gender == 'M') { $enrID = 13 ; }elseif ($event == 'rowing' and $gender == 'M') { $enrID = 14 ; }elseif ($event == 'volleyball(indoor)' and $gender == 'M') { $enrID = 15 ; }elseif ($event == 'volleyball(beach)' and $gender == 'M') { $enrID = 16 ; }elseif ($event == '100 meters' and $gender == 'F') { $enrID = 17 ; }elseif ($event == '200 meters' and $gender == 'F') { $enrID = 18 ; }elseif ($event == '400 meters'and $gender == 'F') { $enrID = 19 ; }elseif ($event == '800 meters' and $gender == 'F') { $enrID = 20 ; }elseif ($event == '1500 meters' and $gender == 'F') { $enrID = 21 ; }elseif ($event == 'Long Jump' and $gender == 'F') { $enrID = 22 ; }elseif ($event == 'High Jump' and $gender == 'F') { $enrID = 23 ; }elseif ($event == 'Shot put' and $gender == 'F') { $enrID = 24 ; }elseif ($event == 'basketball' and $gender == 'F') { $enrID = 25 ; }elseif ($event == 'rowing' and $gender == 'F') { $enrID =26 ; }elseif ($event == 'volleyball(indoor)' and $gender == 'F') { $enrID = 27 ; }elseif ($event == 'volleyball(beach)' and $gender == 'F') { $enrID = 28 ; } $EnrVenID = null ; if ($venueyear == '1984') { $EnrVenID = 1 ; echo "$EnrVenID" ; }elseif ($venueyear == '1988') { $EnrVenID = 2 ; }elseif ($venueyear == '1992') { $EnrVenID = 3 ; }elseif ($venueyear == '1996') { $EnrVenID = 4 ; }elseif ($venueyear == '2000') { $EnrVenID = 5 ; }elseif ($venueyear == '2004') { $EnrVenID = 6 ; }elseif ($venueyear == '2008') { $EnrVenID = 7 ; echo "$EnrVenID" ; }elseif ($venueyear == '2012') { $EnrVenID = 8 ; echo "$EnrVenID" ; } $sql="INSERT INTO Athletes (Athname, Athcountry) values ( '$athname', '$country') " ; $rs=odbc_exec($connection,$sql); $sql4="INSERT INTO Enrollments (EnrMedal, EnrYear, EnrEventID, EnrVenID) values ( '$medal', '$venueyear', '$enrID', '$EnrVenID') " ; $rs4=odbc_exec($connection,$sql4); } echo "<form method='post' action=''>\n"; echo"Please fill out all the fields with the data that you wish to be added: <br/>"; echo"Athelete Name:<input type ='text' Name='athname' > <br/> \n" ; echo"Athelete Country:<input type ='text' Name='country' > <br/> \n" ; echo "Medal: <select name='medal' value='medal'>\n"; echo "<option > </option>\n"; echo "<option $Gold> Gold </option>\n"; echo "<option $Silver> Silver </option>\n"; echo "<option $Bronze'> Bronze</option>\n"; echo "</select>\n" ; echo "Venue Year: <select name='venueyear' value= 'venueyear'>\n"; echo "<option ></option>\n"; echo "<option $1984> 1984 </option>\n"; echo "<option $1988> 1988 </option>\n"; echo "<option $1992>1992 </option>\n"; echo "<option $1996> 1996 </option>\n"; echo "<option $2000> 2000 </option>\n"; echo "<option $2004> 2004 </option>\n"; echo "<option $2008> 2008 </option>\n"; echo "<option $2012> 2012</option>\n"; echo "</select>\n" ; echo "Venue City: <select name='venuecity' value= 'venuecity'>\n"; echo "<option > </option>\n"; echo "<option $LA> Los Angeles </option>\n"; echo "<option $Seoul> Seoul </option>\n"; echo "<option $Barca> Barcelona </option>\n"; echo "<option $ATL> Atlanta</option>\n"; echo "<option $Syd> Sydney </option>\n"; echo "<option $Ath> Athens</option>\n"; echo "<option $Beij> Beijing </option>\n"; echo "<option $Lon> London</option>\n"; echo "</select>\n" ; echo "Venue City: <select name='venuecountry' value= 'venuecountry'>\n"; echo "<option > </option>\n"; echo "<option $USA> U.S.A. </option>\n"; echo "<option $SK> South Korea </option>\n"; echo "<option $Spain> Spain </option>\n"; echo "<option $Aus> Australia </option>\n"; echo "<option $Greece> Greece</option>\n"; echo "<option $Chin> China </option>\n"; echo "<option $UK> United Kingdom</option>\n"; echo "</select>\n" ; echo "Event: <select name='event' value='event>\n"; echo "<option value=''> </option>\n"; echo "<option > </option>\n"; echo "<option $100m> 100 meters</option>\n"; echo "<option $200m> 200 meters </option>\n"; echo "<option $400m>400 meters </option>\n"; echo "<option $800m> 800 meters </option>\n"; echo "<option $1500m> 1500 meters </option>\n"; echo "<option $LongJump> Long Jump</option>\n"; echo "<option $HighJump> High Jumo </option>\n"; echo "<option $Shotput> Shot put </option>\n"; echo "<option $Basketball> Basketball </option>\n"; echo "<option $Rowing> Rowing </option>\n"; echo "<option $Volleyball> Indoor Volleyball </option>\n"; echo "<option $Volley> Beach Volleyball</option>\n"; echo "</select>\n" ; echo "Gender: <select name='gender'>\n"; echo "<option value=''> </option>\n"; echo "<option $Male>M</option>\n"; echo "<option $Female>F</option>\n"; echo "</select>\n" ; echo "<input type='submit' name='search' value='Search' />\n"; echo "</form>\n"; echo "</div>" ; } ?> </body> </html> I have the really long IF statements in there so that it enters the correct EnrID and EnrVenID into the database, to make sure it fills out all fields. I am using Microsoft access for my database. The problem is that it will only fill in the athlete's name and country, and not his/her enrollment information (what medal they got, their enr ID, what year it was taken place, etc. The problem with my login system is that I want the user to login with a username and password if they wish to be an admin, but the login system doesn't work. the variables aren't passed through the system for some reason, even though it worked a week ago, but now it doesn't. The code is Code: [Select] if(isset($_POST['username'])){ $username= $_POST['username'] ; } if(isset($_POST['password'])){ $password= $_POST['password'] ; } $username = null ; $password = null ; Thanks for any help I currently have a MyBB forum and I'm going to attempt to create a top list for it, but I'd like users that have already registered on my forum to be able to log into the top list area and either add or edit their website on the top list. How would I go about creating a login script with an already existing MySQL database that contains my MyBB users? Ok. I am trying to create a customer tracking database that will allow me to get a handle on my customer support inquiries. To do this I have created a database that will store all of a customers pertinent information and then I plan on creating another table that will be 'Notes' where each note is associated with a customerID. I have created the form fine where I can input the data into the table but I am having issues with the next part. I would like to have a list/menu that will display all of the current users in the database. Then when I click on one of those it will display that information in the form so that I can view it, edit it, or delete it. But I have been stumped for multiple days and other php forums have been absolutely worthless. I know that php can pass a variable name in the address but I have no idea how to do that or how to use it when it's in the address. I know I'm a newb. Please help. I really need to move on from this hurdle. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <link href="maxxTraxx.css" rel="stylesheet" type="text/css" /> </head> <body> <?php //Load Database Connectivity and Form Helpers require 'DB.php'; require 'formhelper.php'; //Connect To Database $db = MY CONNECTIVITY IS FINE, HIDING FOR SECURITY PURPOSES if (DB::isError($db)) { die("Cant connect: " .$db->getMessage()); } //Print Message and Quit on Future Database Errors $db->setErrorHandling(PEAR_ERROR_DIE); customerList(); //Main Page Logic if ($_POST['_submit_check']) { foreach($_POST as $key=>$value) { if($key == 'saveCustomer') { //If validate_form() returns errors, show them the form with errors if ($form_errors = validate_formCustomer()) { show_form($form_errrors); } else { //The submitted data is valid, so process it process_formCustomer(); } } if($key =='go') { print $_POST['customerList']; } } }else { //The form wasn't submitted, so display it blank show_form(); } //------------FUNCTIONS--------------------------------------------------------- function show_form($errors = '') { //If the form is submitted, get defaults from submitted parameters if ($_POST['_submit_check']) { $defaults = $_POST; } else { //Otherwise set your own defaults $defaults = ''; } //If errors were passed in, put them in $error_text (with HTML markup) if ($errors) { $error_text = '<tr><td>You need to correct the following errors: '; $error_text .= '</td></tr><ul><li>'; $error_text .= implode('</li><li>',$errors); $error_text .= '</li></ul></td></tr>'; } else { //No errors? Then $error_text is blank $error_text = ''; } $states = array('AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY', 'Canada', 'Puerto Rico', 'Australia'); $status = array(1=>'Fine', 2=>'Received', 3=>'In Repair', 4=>'Waiting', 5=>'Shipped'); $months = array(1=>'January', 2=>'February', 3=>'March', 4=>'April', 5=>'May', 6=>'June', 7=>'July', 8=>'August', 9=>'September', 10=>'October', 11=>'November', 12=>'December'); $days = array(); for($i = 1; $i <=31; $i++) { $days[$i] = $i; } $years = array(); for($year = date('Y') , $max_year = date('Y')+5; $year < $max_year; $year++) { $years[$year] = $year; } //Jump out of PHP mode to make displaying all the HTML tags easier but still inside the show_form function ?> <div class="customerForm"> <center><h2>Customer Form</h2></center> <form method="post" action="<?php print $_SERVER['PHP_SELF']; ?>"> <table> <?php print $error_text ?> <tr><td>Last Name</td> <td><?php input_text('customerNameLast', $defaults); ?>, </td> <td>First Name</td> <td><?php input_text('customerNameFirst', $defaults); ?></td> <td>Phone Number</td> <td><?php input_text('customerPhone', $defaults); ?></td></tr></table> <table><tr><td>Address</td> <td><?php input_text('customerAddresss', $defaults); ?></td> <td>City</td> <td><?php input_text('customerCity', $defaults); ?></td> <td>State</td> <td><?php input_select('customerState', $defaults, $states); ?></td> <td>Zip</td> <td><?php input_text('customerZip', $defaults); ?></td></tr></table> <table><tr><td>Email</td> <td><?php input_text('customerEmail', $defaults); ?></td> <td>RMA #</td> <td><?php input_text('customerRMA', $defaults); ?></td> <td>Parts Out</td> <td><?php input_text('customerPartsOut', $defaults); ?></td></tr></table> <table><tr><td>Status</td> <td><?php input_select('customerStatus', $defaults, $status); ?></td> <td>Due Date</td> <td><?php input_select('customerDueMonth', $defaults, $months); ?> <?php input_select('customerDueDay', $defualts, $days); ?> <?php input_select('customerDueYear', $defaults, $years); ?></td></tr></table> <center><?php input_submit('saveCustomer', 'Save Customer'); ?></center> <input type="hidden" name="_submit_check" value="1"/> </form> </div> <?php }//End of the show_form() function function validate_formCustomer() { $errors = array(); return $errors; } function process_formCustomer() { global $db; //Get a unique ID for Customer $customerID = $db->nextID('customerID'); $customerDueDate = $_POST['customerDueYear'].'-'.$_POST['customerDueMonth'].'-'.$_POST['customerDueDay']; $db->query('INSERT INTO Customer (customerID, customerNameLast, customerNameFirst, customerPhone, customerEmail, customerAddress, customerCity, customerState, customerZip, customerStatus, customerPartsOut, customerRMA, customerDueDate) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)', array($customerID, $_POST['customerNameLast'], $_POST['customerNameFirst'], $_POST['customerPhone'], $_POST['customerEmail'], $_POST['customerAddress'], $_POST['customerCity'], $_POST['customerState'], $_POST['customerZip'], $_POST['customerStatus'], $_POST['customerPartsOut'], $_POST['customerRMA'], $customerDueDate)); //Tell the user that we adde a customer print '<center>Added '.htmlentities($_POST['customerNameLast']) .' to the database.</center> <br /><br />'; print '<center><a href="/maxxTraxx/index.php">Back To The Admin</a></center>'; }//End of process_formCustomer function function customerList() { global $db; $qCustomers = $db->query('SELECT customerID, customerNameLast, customerNameFirst FROM Customer'); print '<div class="customerList"><form action="test.php" method="get">'; print '<select name="customerList" size="30">'; while($row = $qCustomers->fetchRow()) { $qAllCustomers[0] = $row[0]; $qAllCustomers[1] = $row[1]; $qAllCustomers[2] = $row[2]; //print $row[0]; //print 'Customer #'.$qAllCustomers[0].' is: '.$qAllCustomers[2].' '.$qAllCustomers[1].''; print '<option value="'.$qAllCustomers[0].'" selected>'.$qAllCustomers[1].', '.$qAllCustomers[2].'</option>'; } print '</select></form></div>'; echo $_POST['customerList']; input_submit('go', 'go'); //return $qAllCustomers; } ?> </body> </html> This topic has been moved to Beta Test Your Stuff!. http://www.phpfreaks.com/forums/index.php?topic=307377.0 I have three small tables and I'm looking for a clean, light, framework CRUD generator that I can use. Are there any that are small and light that dont require a full blown install like Symphony or phpObject Generator etc... Jared Hey sorry that I am asking this question, though I have gotten around to learn connecting to a database and also do the retrieve, yet I am not necessarily getting to learn doing INSERT, UPDATE and DELETE the proper way.
The tutorials available are often not best, I have found a good book ("Object Oriented Programming in PHP5") which teaches SELECT, yet not necessarily INSERT, UPDATE and DELETE.
I am really wondering how does one get to learn CRUD with PHP OOP, how did you people learn this? How can I learn INSERT, UPDATE and DELETE as well with PHP OOP? I feel like paying for this on Elance or Fiverr. I am not sure how else to learn this by now, I have tried quite a bit, I have looked at scripts and tutorials and books. And it has just gotten as far as connecting to the database and doing the "fetching" ("SELECT", or also "retrieve"). Too bad that what is available is not necessarily best. Otherwise I would say one could understand the principle quickly and also pick up on a programming language quickly. Please bear with me, I would appreciate suggestions. Hi all, iv benn search for a long time now for a sample on how to create MYSQL based data grid that have some CRUD functionality.. i am using dreamwever and the only thing i can get out of it is using the spray data set that gives me a table with sort abilities but i am looking for something more.. is there a PHP or JS sample of displying the data of MYSQL database that can can do CRUD and search abilities ? thank.. Hi, I am creating my first OOP MVC content management system. I created a CRUD where on the Tag view page, you click edit and it takes you to the Tag edit page. But I want to improve the user experience, so when a user clicks edit, a modal window displays allowing editing of Tag, upon clicking save, modal window closes and AJAX updates Tag view page without refresh. You can see my Tag view.html here which is using Twig template system: {% extends "backendbase.html" %} {% block title %}Manage Tags{% endblock %} {% block body %} <h1 class="ui header">View Tags</h1> {% if tags.errors is not empty %} <div class="ui error message"> <p>Errors:</p> {% for error in tags.errors %} <div>{{ error }}</div> {% endfor %} </div> {% endif %} <table class="ui striped table"> <thead> <tr> <th>Id</th> <th>Tag</th> <th>Directory</th> <th>Synonyms</th> <th>Edit</th> <th>Test</th> <th>Delete</th> </tr> </thead> <tbody> {% for tag in tags %} <tr> <td>{{ tag.id }}</td> <td>{{ tag.tag }}</td> <td>{{ tag.tag_dir }}</td> <td>{{ tag.synonyms }}</td> <td><a class="edit" onclick="return false;" href="../edit/?edit={{ tag.id }}">Edit</a></td> <td><a href="../test/?test={{ tag.id }}">Test</a></td> <td><a href="../delete/?delete={{ tag.id }}">Delete</a></td> </tr> {% endfor %} </tbody> </table> <div class="ui modal"> <i class="close icon"></i> <div class="header"> Edit Tag </div> <div class="image content"> <!--<div class="ui medium image"></div>--> <div class="description"> <!-- <div class="ui header">We've auto-chosen a profile image for you.</div> <p>We've grabbed the following image from the <a href="https://www.gravatar.com" target="_blank">gravatar</a> image associated with your registered e-mail address.</p> <p>Is it okay to use this photo?</p> --> </div> </div> <div class="actions"> <div class="ui black deny button"> Cancel </div> <div class="ui positive right labeled icon button"> Save <i class="checkmark icon"></i> </div> </div> </div> <div class="ui divider"></div> <div class="ui pagination menu"> {% for page in pages %} <a href="{{ page.number|e }}" class="{{ page.isactive|e }}">{{ page.number|e }}</a> {% endfor %} </div> {% endblock %} If I add a form in the modal window with {{ tag.id }} and {{ tag.name }}, nothing displays obviously because it is not in the for in loop. My question is, what is the industry standard way of getting data into this modal window form? I could use a $_GET["id"] but then I am breaking MVC model by including code in template. Is the solution to use JavaScript to get ID from edit link, in the background get data from database then use JavaScript to create form in modal? Your help would be much appreciated! Hello my good people
I'm doing a content manager system in PHP and mySQLi, following a serie of video tutorials.
But in my project I am using a tree menu.
In the front office all works smoothly (the tree menu displays all results - menu and submenus - and each button carries the information of the respective page). I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. |