Monday 27 March 2023

seeking help from chatGPT for coding :)

 All the below took some 30 odd minutes? .. only config.php needed custom login/credentials .. edit.php is still NOT working - have to figure out :)


me:
can you write a CRUD application in PHP
Sure, I can provide a basic example of a CRUD application in PHP using MySQL as the database. Here's an example code for a simple book management system:
php [Stopped half-way it seems AFTER good 80-90 lines of code]
<input type=
me:
what will be the SQL to create table for this?
Here's an example SQL code to create a table called "books" for the book management system:
[gave a useful SQL query to create relevant table]
This code creates a table with four columns: "id", "title", "author", and "price". The "id" column is set to auto-increment, which means a unique value will be generated automatically for each new record added to the table. The "title", "author", and "price" columns are set to not allow null values. The "price" column is defined as a decimal with 10 digits and 2 decimal places. The primary key of the table is set to the "id" column.

me:
any CSS you suggest for this sample application?
Sure! Here's an example CSS code that you can use to style the book management system:
[Responds with CSS code applies basic styles ..]

me:
i asked to regenerate because the php code you originally responded with seems to be incomplete - the books crud sample
I apologize for the confusion. Here's a complete example of a CRUD application for managing books using PHP:
[This time responds with - index.php, add.php, edit.php ...]

me:
where is delete.php?
I apologize for the oversight. Here's the code for delete.php:
[gives that php too ..]
You can use this file to delete a book from the database. When you click the "Delete" button for a book in the index.php file, it will send a POST request to delete.php with the book's ID. The script will then delete the book from the database and redirect back to the index.php file.

me:
and seems config.php too is needed Yes, you're correct. Here's an example of what config.php could look like:
[now, it is done?!]
You would need to replace "your_username", "your_password", and "your_database_name" with your actual database credentials. This file is used to create a database connection that can be reused across multiple PHP files in your application.

No comments:

Post a Comment