0

Main problem: connect exsited mysql and website , that making change on mysql can reflect to website too


(ps. the Django way will stock on no way to connect exsist websit and MySQL)

  • tried method A :

even though the Django way can connect MySQL and Django, but still not lead to change mysql reflect to website too


Demo idea result : (refer to author DC con, his example Concretization my aim)
if I update/change the context Nordic as Nike from mySQL, by success connect both, the website part the Nike can replace Nordic as new topic

enter image description here

I read through all the relate question, they either not 100% same to mine issue, or that issue don't get solution, or I tried the solution, but not worked , thanks

1 Answers1

-1

You should be able to run a SQL query and render it in HTML, as shown for example by this question.

A. Darwin
  • 244
  • 1
  • 7
  • I have read through that post before I post the question, I think Django create new website/page for showing result, I want `showing result to exsited website`, which I'm looking for the way to `connect exsited website and mySQL` –  Jan 05 '23 at 09:14
  • @pythoncoder Using Django or similar frameworks, you can dynamically generate HTML pages, which are not just static pages but show some variable output. The standard way to do this in Django is using the render method. As long as you can run a SQL query and save the result in a variable, you can render it using the render method. Both steps are shown in the thread I linked. If you're asking how to show a query output to an existing website that you cannot control, that's of course impossible unless you find an exploit a SQL injection attack (which is very likely illegal wherever you are). – A. Darwin Jan 05 '23 at 09:18
  • hi @A. Darwin, thanks for ur message, our company own the website, and after finished set all the website layout, just need me to connect mySQL and **that finish website** , I just don't know how –  Jan 05 '23 at 09:46
  • even though you mention I can "dynamically generate HTML pages", but that create the new website, I'm looking for connecting the old one, and result like the demo pic in example post above –  Jan 05 '23 at 09:48
  • @pythoncoder in that case, run some SQL query from the Django code (example from the Django docs: cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz]), save the result in a variable and render it as HTML. If the page is currently static, look into how to add variables to a HTML template: https://stackoverflow.com/questions/1070398/how-to-set-a-value-of-a-variable-inside-a-template-code – A. Darwin Jan 05 '23 at 09:51