Php procedural CRUD

GSquadron

Member
Sep 8, 2012
172
0
0
I have problems learning crud using php and procedural programming.
I have 1.5 years with php and I know a lot from the basics, but this crud really is not my best. Can anyone help with this? I have found object oriented cruds, but not procedural and i dont want it oop since i never used object oriented to create a webiste.
 

beginner99

Diamond Member
Jun 2, 2009
5,315
1,760
136
???

If you don't use and ORM it does not matter at all if you do it procedural or OO because SQL is neither of both.

Create = INSERT (your data)
Read = SELECT (your data)
Update = UPDATE (your data)
Delete = DELETE (your data)

I don't see the problem at all.
 

GSquadron

Member
Sep 8, 2012
172
0
0
Ok, thanks for the reply

The whole problem is that when i try to create something, like a link with the name for example Anand and when i click on that i don't understand how am i supposed to send the user to the anand article??? It has the same name
Can you help? Or at least provide a link to that?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,609
4,530
75
I'm confused. You don't know what an "href" (Hypertext REFerence) is in HTML, or you haven't figured out how to send the Anand article from a PHP site?

You have to be CRUDding in some kind of backend, like a database. What are you using?
 

GSquadron

Member
Sep 8, 2012
172
0
0
I am using MySQL and i know the basics. I don't understand the logic behind that.
I don't know how to Edit posts and how to delete them using CRUD so others will delete them without me making additional coding.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I am using MySQL and i know the basics. I don't understand the logic behind that.
I don't know how to Edit posts and how to delete them using CRUD so others will delete them without me making additional coding.

I think you may be a little confused. I know I am :). CRUD is just an acronym that refers to Create, Read, Update, Delete. It's shorthand for "the basic things any website does with data."

If you use an automatic data mapping layer (ORM, as previously mentioned) then you perform these CRUD operations against that layer. If not, then you write your own data access code to perform the operations.
 

GSquadron

Member
Sep 8, 2012
172
0
0
You mean if I search and study the ORM, the users won't have to write the code, but simply press edit, delete and new?
If that is what you mean, than it is what i am searching for! :)

Please provide any source where i can learn that, it seems too difficult to find.
 
Last edited:

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
You mean if I search and study the ORM, the users won't have to write the code, but simply press edit, delete and new?
If that is what you mean, than it is what i am searching for! :)

Please provide any source where i can learn that, it seems too difficult to find.

It's not at all difficult to find, but you don't know what you're looking for, and that might make it a little harder :).

Bottom line, to proceed down the path you seem to be pursuing you would need a base of programming and system knowledge that you appear not to have. There are platforms that require little to no programming, Wordpress for example, and you may want to check out something along those lines, depending on the sort of site you want to build.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
It might even be a good idea to go with Wordpress.com hosting so you don't need to worry about your site being hacked.
 

GSquadron

Member
Sep 8, 2012
172
0
0
I have already built my website from scratch with html, css, jquery, php, mysql
Have a look yourself: www.anothergames.com
I started reading a book about php and mysql, but what I am missing here, is how I create an easy way for others to add their own content on the website, without needed knowledge of a single HTML code. This is what i am trying to do.
The book I am reading perfectly explained MySQL, insert into, delete, create, update, but the real problem is, how am I supposed to use this MySQL combined with PHP and create a webpage, using sessions, so the users will upload their own stuff.
For example, if I payed someone to work for my website and he doesn't know a single HTML code, I will certainly need to do this. I want it for time saving too, since I have to add coding every time I try to add new content.
Or better saying make my own CMS
I am totally against pre-build CMS, especially now that the website is in a very good state.
(when it comes to hacking, I have already used php functions and Google's anti-bots questions on the forums)

@Mark
Looks like I appear to have the knowledge you are talking about
 
Last edited:

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
It sounds like you are looking for a "content management system."

Wordpress is one example of a CMS, but a Google search will turn up more like Drupal.

If you use an existing CMS, it saves a huge amount of work, but you also must be good about installing patches. Because these CMS are used on tens of thousands of websites, there is money to be made in attacking them to take them over and add spam and viruses.

If you write your own CMS, it will be a lot more work but could have exactly the features you want. There is the risk that you won't get the security right, so someone can find a hole to take over your server.
 

GSquadron

Member
Sep 8, 2012
172
0
0
I actually am looking for the crud features from the whole CMS
I am not that good to create an entire CMS, so only crud will do.
Any help? Again.....
 

Cerb

Elite Member
Aug 26, 2000
17,484
33
86
Most confusing thread ever!
Truth!

Web apps pretty much all start from CRUD and go up in complexity from there.

If you don't understand how to tie HTML, PHP, and MySQL together, you definitely do not have the knowledge Markbnj speaks of. If you did, you'd be doing it--the info is out there, and you'd be looking up specific feature details and gotchas. I'm guessing you procedurally know how to use PHP, HTML, and Javascript, but don't understand the underpinnings of managing data. Persistent files and DBs require their own kind of thinking.
The book I am reading perfectly explained MySQL, insert into, delete, create, update, but the real problem is, how am I supposed to use this MySQL combined with PHP and create a webpage, using sessions, so the users will upload their own stuff.
This is handled in many LAMP tutorials, and is basically what PHP is there to do, these days. You have options as to how to implement it, but if you understand how it works, the interface will be the hard part (YUI for reasonable image support?).

Your site as it is would be a perfect candidate for a Wordpress conversion, IMO. Wordpress, specifically, tries to keep updates from causing regressions, so patching is much safer than with, say, Drupal; and it's fairly easy to customize the look and feel. Don't succumb to NIH syndrome.
 

beginner99

Diamond Member
Jun 2, 2009
5,315
1,760
136
Whats the actual background of this?

I'm gonna be blunt. The whole thread has this touch about "I'm lazy and don't want to learn but I want to get rich with my great web site idea."

Programming isn't something you just can. to come up with something good you will need experience and lots of it. It's even more problematic when creating a public available web site. You either won't be successful or get hacked.

If you write your own CMS, it will be a lot more work but could have exactly the features you want. There is the risk that you won't get the security right, so someone can find a hole to take over your server.

Considering how the thread went up till now I don't see this as a risk, more like a fact...
 

Wyndru

Diamond Member
Apr 9, 2009
7,318
4
76
He will be fine, we all just set him up for that haha.

That's how I started, constructive criticism.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
@Mark
Looks like I appear to have the knowledge you are talking about

If you did that stuff from scratch, then yeah, you should have picked up a lot of what we've been discussing. Perhaps this has been a language issue. When I read a statement like this one...

I actually am looking for the crud features from the whole CMS
I am not that good to create an entire CMS, so only crud will do.
Any help? Again.....

... that is just not how a person who understands the problem would describe it. I'll try again. The acronym CRUD is useless in this context, so stop using it. We all know what CRUD is. It's short for "I don't see why this should take more than half a day; it's just CRUD."

In other words, it's usually spoken by people who don't really know what it means. Once you get past the jargon, you have actual stuff that you need to put in an actual database in response to actual user iinput. Describe your real problem, and maybe we can help. You want to read and write what? Forum posts? Blog entries? Stock quotes? Music files? Football stats?

In the real world we programmers have to know the specific, minute details of every problem domain we work in. It's not just "CRUD."
 

GSquadron

Member
Sep 8, 2012
172
0
0
ok, but it is hard to explain, at least for me.
I want to create an admin account where only me, will be able to EDIT, DELETE, INSERT and CREATE articles. To do that, first of all, I want to add a button, which only the admin account can see in the reviews section, with the statement ADD NEW REVIEW. After this, I will have to create a page which will have a form to write the review and a submit button. The big problem is that if I add in the title textbox the name for example "Far Cry 3 review", how it is supposed to become a link this title, so people will click on the title after I submit the review and go to a page named "\far%20cry%203%20review" and read the Far Cry 3 title + the whole review with images. I know how to add the reviews and add the info on the database, but the problem which I don't understand at all is: How am I supposed to create this link with the Far Cry 3 title so when a user clicks on it goes to a page which has the review?

So 2 things to discuss: How to appear and dissapear that button and the link. Not talking about how to create sessions or other users who will add info. I need only these 2 things. I am going on reading this book which explains PDO and seems very different from the normal way used. I will find this one day, normally, but since I need help for now, I just need it to add stuff meanwhile I learn new stuff.

About that part of getting money... 2.5 months old is a joke, so I don't see how to get the money with this young website. I am not doing it for the money at all, it is an experience and learning source, rather than earning.

And yes, you are right, I don't really need the crud stuff, just specific problems I came into.

I was thinking now, if the $_GET['review']; should be used on the link
or $review = "SELECT * FROM review WHERE name='Far Cry 3'"
This is alright, but the problem is how to make this a link???
/'.$title.' ???? It just doesn't make sense.
 
Last edited:

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I have already built my website from scratch with html, css, jquery, php, mysql
Have a look yourself: www.anothergames.com

I checked out that website, and what I don't get is how you built it from scratch without coming to some understanding of the things you're asking about? It already does most of them. For example, how do the review links on that site work?

The features you've asked about you'll get out of the box using Wordpress, and there are already packaged versions for review sites and the like. That direction is still the one I would recommend to you.
 

GSquadron

Member
Sep 8, 2012
172
0
0
It is simply a function thing I am missing.
It has nothing to do with rewritting, but I need a need for pointing to that review.
btw, I add reviews manually, writting all the code and it sucks up a lot of time.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,609
4,530
75
Are you just looking for the urlencode function?

You should totally use a pre-built CMS like Wordpress or Drupal. Drupal is open-source and you can rewrite it to your heart's content.
 

GSquadron

Member
Sep 8, 2012
172
0
0
Looks like the book I am reading gives the solution to my problem, but I will have to change everything to PDO connections. Don't worry anymore guys, since I guess this is exactly what I was searching and am studying it right now.
 

cytg111

Lifer
Mar 17, 2008
25,599
15,123
136
Most confusing thread ever!

No, not really, it is quite obvious that the OP read the magic "CRUD" acronym somwhere but has not realized what it actually means.

Create Read Update Delete, and is just another way of referencing some section of code that does database IO, persistence, drives the nail in, whatever.

I must give cudos to the OP cause it sounds like you're in way over your head and you're still hanging in there .. Dont give up, keep reading :).

edit. reading the rest of the thread, I'm sorta confused too. Doesnt add up.