Php procedural CRUD

Discussion in 'Programming' started by GSquadron, Dec 22, 2012.

  1. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.
     
  2. Loading...

    Similar Threads - procedural CRUD Forum Date
    Calling a procedure that exists in another code segment Programming Jan 6, 2017

  3. beginner99

    beginner99 Diamond Member

    Joined:
    Jun 2, 2009
    Messages:
    3,168
    Likes Received:
    94
    ???

    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.
     
  4. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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?
     
  5. Ken g6

    Ken g6 Programming Moderator, Elite Member
    Moderator

    Joined:
    Dec 11, 1999
    Messages:
    12,648
    Likes Received:
    295
    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?
     
  6. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.
     
  7. Markbnj

    Markbnj Elite Member <br>Moderator Emeritus
    Moderator

    Joined:
    Sep 16, 2005
    Messages:
    15,688
    Likes Received:
    8
    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.
     
  8. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.
     
    #7 GSquadron, Dec 23, 2012
    Last edited: Dec 23, 2012
  9. Markbnj

    Markbnj Elite Member <br>Moderator Emeritus
    Moderator

    Joined:
    Sep 16, 2005
    Messages:
    15,688
    Likes Received:
    8
    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.
     
  10. DaveSimmons

    DaveSimmons Elite Member

    Joined:
    Aug 12, 2001
    Messages:
    39,458
    Likes Received:
    239
    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.
     
  11. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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
     
    #10 GSquadron, Dec 24, 2012
    Last edited: Dec 24, 2012
  12. DaveSimmons

    DaveSimmons Elite Member

    Joined:
    Aug 12, 2001
    Messages:
    39,458
    Likes Received:
    239
    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.
     
  13. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.....
     
  14. Graze

    Graze Senior member

    Joined:
    Nov 27, 2012
    Messages:
    468
    Likes Received:
    0
    Most confusing thread ever!
     
  15. Cerb

    Cerb Elite Member

    Joined:
    Aug 26, 2000
    Messages:
    17,409
    Likes Received:
    0
    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.
    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.
     
  16. beginner99

    beginner99 Diamond Member

    Joined:
    Jun 2, 2009
    Messages:
    3,168
    Likes Received:
    94
    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.

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

    Wyndru Diamond Member

    Joined:
    Apr 9, 2009
    Messages:
    7,319
    Likes Received:
    1
    He will be fine, we all just set him up for that haha.

    That's how I started, constructive criticism.
     
  18. Markbnj

    Markbnj Elite Member <br>Moderator Emeritus
    Moderator

    Joined:
    Sep 16, 2005
    Messages:
    15,688
    Likes Received:
    8
    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...

    ... 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."
     
  19. clamum

    clamum Lifer

    Joined:
    Feb 13, 2003
    Messages:
    24,087
    Likes Received:
    42
    I are confuse.
     
  20. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.
     
    #19 GSquadron, Dec 26, 2012
    Last edited: Dec 26, 2012
  21. Markbnj

    Markbnj Elite Member <br>Moderator Emeritus
    Moderator

    Joined:
    Sep 16, 2005
    Messages:
    15,688
    Likes Received:
    8
    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.
     
  22. beginner99

    beginner99 Diamond Member

    Joined:
    Jun 2, 2009
    Messages:
    3,168
    Likes Received:
    94
    The technical term you are looking for is

    url rewriting

    Use google.
     
  23. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.
     
  24. Ken g6

    Ken g6 Programming Moderator, Elite Member
    Moderator

    Joined:
    Dec 11, 1999
    Messages:
    12,648
    Likes Received:
    295
    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.
     
  25. GSquadron

    GSquadron Member

    Joined:
    Sep 8, 2012
    Messages:
    172
    Likes Received:
    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.
     
  26. cytg111

    cytg111 Diamond Member

    Joined:
    Mar 17, 2008
    Messages:
    3,398
    Likes Received:
    283
    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.