Doubt about mysql - Save, Update and Show data

Asked

Viewed 141 times

1

Talk guys! I have a question. I created a static page that will show some data.
For example, I want to show you the live score of a specific football game.
Exemplo "Mostrar Dados" - Página Estática

I thought of creating a static page with:

  • "Championship Name"
  • "Name of Team A"
  • "Emblem of Team A" (Image)
  • "Name of Team B"
  • "Emblem of Team B"(Image)
  • "Outcome of the Game"

To facilitate data entry I thought of building a form to insert this information in a database. But I am in doubt if this is the best way to execute.

1 - Is it possible for me to create a "Enter data" page, leave pre-registered the teams/championships and select through a form with check box? For example:

Página"Inserir dados" - Formulário

2 - Is sending the above form always replace the row in the table? So on the show page would always fetch the same data?

Thank you for your attention.

  • Possible is, the point is that you have several ways to do this. I found your question kind of generic

  • So @Emirmarques I wanted to know the easiest way to redeem these values. Because on the "send form" page I will create a check box with the values to be saved. For example, when selecting "Cruise" and recording. When opening the "Show Data" page it will update with the recorded data in the table.

2 answers

1


Only with HTML and Mysql no - you’ll need to have another technology in the middle - a programming language in the backend: be it Python, PHP, or other.

It may be possible to do something by connecting html-5 Javascript directly to the database - however I don’t see Uta getne doing it, and it would be something inherently unsafe: if you try to do this the greater chance is that of unrestricted access to anyone to your entire database. (it is possible to do "right", but it will require a level of customization of your bancod and data quite different from the common use of banks and will require far more expertise than, say, developing what you need in PHP or using a Python framework like Flask or Web2py)

0

To write in python the recording is like this :

from flask import Flask,request,redirect,url_for,render_template
import mysql, MySQLdb, mysql.connector

app = Flask(__name__)

DB = mysql.connector.connect(
  host="localhost", 
  port="3306",
  user="usuario",
  password="senha",
  database="banco",
  auth_plugin='mysql_native_password'
  )

conexao = DB.cursor()

SQL_COMMAND = "INSERT INTO tabela(campeonato, timea, timeb, resultado) VALUES (%s, %s, %s, %s )"
VALORES = [
  ('CAMPEONATO', 'TIMEA', 'TIMEB', 'RESULTADO')
]

conexao.executemany(SQL_COMMAND, VALORES) 

DB.commit()

conexao.close()

DB.close()

if __name__ == "__main__":
    app.run(debug=True)

hope I’ve helped

Browser other questions tagged

You are not signed in. Login or sign up in order to post.