php - Creating a table on HTML with information from various MySQL tables -


I have a website that I'm building for a school project, in which I already have many webpages , Though, and the database through the use of Foreach.
But on the question in this page, I am trying to retrieve data from different tables, so that a user can choose a category and submit a text and submit it.
But for some reason it is not outputting any data if I try with only one table and without using the table.field method, and just typing the fields, it works.
But for everything I know, I have to do this from various tables.
annione help me on this? & lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php mysql_connect ("localhost", "root", "") or die ("problema na conexao"); mysql_select_db ("trabalho1"); $ Query = "Select Technofitito, Tex.id, categoria.categoria, categoria.id from categoria, texto"; $ Result = mysql_query ($ query) or die (mysql_error ()); Echo "& lt; center & gt;"; Echo "& lt; table border = '2' & gt; \ n"; Echo "form

& lt; / tr & gt; "; Echo "& lt; tr & gt; & lt; td colspan = '2' & gt; Textto & lt; / td> & lt; td colspan = '2' & gt; Categoria & lt; / td & gt; ; & lt; / tr & gt; "; {$ Line = mysql_fetch_assoc ($ result)) {foreach ($ $ camp = $ $ line as valor) {if ($ campo == "texto.titulo") {resonant "<<" lt; td & gt; '". Valor. $ '' & Lt; / td & gt; "; } If ($ camp == "Texo.id") {resonates " & lt; / tr & gt;"; } If ($ camp == "categoria.categoria") {resonant ";" $ valor "'& Lt; / td & gt;"; } If ($ camp == "categoria.id") {resonates "lt; td & gt; & lt; input type = 'radio' name = 'value' = ''. $ Heroism "'& gt; & lt; / td> & lt; / tr & gt;"; }}} Echo ""; Echo "& lt; / table & gt;"; Echo "& lt; / center & gt;"; ? & Gt; & Lt; / Body & gt; & Lt; / Html & gt;

Added: Since both tables have a field called ID, it will not let me enter field names, I will also have to give the table name as I did. And yes, I've verified and both tables are populated with data, they work fine on other pages.

This is what I recommend (I did not consider too much code optimization).

  & lt ;? Php $ data = array (); Mysql_connect ('localhost', 'root', '') or die ('problema na conexao'); mysql_select_db ('trabalho1'); // Use same field-names / aliases: id, info $ query = 'ID as ID ID, information as title'; $ Result = mysql_query ($ query) or die (mysql_error ()); While ($ line = mysql_fetch_assoc ($ result)) {$ data [] = $ line; } // Use the same field-names / aliases: id, info $ query = 'SELECT id,' class' from information as categoria; $ Result = mysql_query ($ query) or die (mysql_error ()); While ($ line = mysql_fetch_assoc ($ result)) {$ data [] = $ line; }? & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; / Head & gt; & Lt; Body & gt; & Lt; Center & gt; & Lt; Table border = '2' & gt; & Lt; Form id = 'formulario' name = 'post' method = 'post' onsubmit = 'return valid (this) = action. & Lt; Tr & gt; & Lt; td colspan = '2' & gt; & Lt; Button type = 'submit' & gt; Submitter & lt; / Button & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; td colspan = '2' & gt; Histororo de newsletters & lt; / Td> & Lt; td colspan = '2' & gt; Invite newsletter & lt; / Td> & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; td colspan = '2' & gt; Textto & lt; / Td> & Lt; td colspan = '2' & gt; Categoria & lt; / Td> & Lt; / Tr & gt; & Lt ;? php foreach ($ data as line $) {echo '& lt; Td> & Lt; Input type = "radio" name = "noam" value = "'. $ Line [' id ']. 
& lt; / td> & lt; / tr & gt;'. '& Lt; tr & gt; & lt; td & gt; . $ L [/ id &

PS: Read about my response to double quotes.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -