How to apply media query in table?

PHP Retrieve Table with Query?

  • Hello, I am looking for help with a website that I am creating a sports recording website to record data as and when it happens during the game. I have created the website to insert records into the database on a separate page but want another page to retrieve the recordings of the game. I have managed to retrieve the table no problem but want to change it so that a user can customise what they wish to be viewed from the database. For example, instead of retrieving all the stats from the table, a user may wish to see how one individual player has performed as I have many players in the database. The way I want this to be achieved is to prevent the table to be shown until the user has selected a check box to retrieve all the information and pressed a submit button to complete the query Here is the code below: <input type="check box" name="selectAll" id="selectAll" value="SelectAll"/>Select All Players <input name="submit" type="submit" value="Submit"> <br/><br/> <?php //Set the variables for the database access: $db_host = ""; $db_username = ""; $db_password = ""; $db_name = ""; $db_table = ""; $Link = mysql_connect("$db_host", "$db_username", "$db_password") or die ("Could not connect to MySQL"); $Table = "SELECT * from $db_table"; mysql_select_db ($db_name,$Link); $Result = mysql_query ($Table,$Link); print ("<TABLE BORDER=1 WIDTH=\"60%\"CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>\n"); print ("<TR ALIGN=CENTER VALIGN=TOP>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Number</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>NumberTo</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Pass</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Shots</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Penalty</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Freekick</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Offside</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Corner</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>LostPossession</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>PositionStart</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>PositionEnd</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Tackle</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Clearance</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>Booking</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>ShotsAgainst</TD>\n"); print ("</TR>\n"); while ($Row = mysql_fetch_array($Result)) { print ("<TR ALIGN=CENTER VALIGN=TOP>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[number]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[Numberto]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[pass]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[shots]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[penalty]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[freekick]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[offside]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[corner]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[lostPossession]</TD>\n")... print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[positionStart]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[positionEnd]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[tackle]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[clearance]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[booking]</TD>\n"); print ("<TD ALIGN=CENTER VALIGN=TOP>$Row[ShotsAgainst]</TD>\n"); print ("</TR>\n"); } mysql_close($Link); print ("</TABLE\n"); ?> Thanks for the help in advance, it is very much appreciated!! Mike

  • Answer:

    if ($_POST[selectAll] == "selectAll"){ $Table = "SELECT * from $db_table"; }else if ($_POST[selectAll] == "playername1"){ $Table = ("SELECT * from $db_table WHERE `player` = 'playername' "); }

Mark O at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

if ($_POST[selectAll] == "selectAll"){ $Table = "SELECT * from $db_table"; }else if ($_POST[selectAll] == "playername1"){ $Table = ("SELECT * from $db_table WHERE `player` = 'playername' "); }

Mark O

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.