Advice On Sorting Results (in A Table): Session Variables?
I have a table of query results (from PostgreSQL) that I am displaying using PHP. I would like to give the user the option to sort the results by clicking on one of the various table headings. I know that I can sort them at the time that I query them, but this would require a new database query each time. I am thinking of making the heading a hyperlink similar to the following:
<a href=myresultspage.php?sort=price>
//this would be the link to sort by the price collumn.
I have managed to make a simple sorting function, by putting the results into an array then sorting the array by the appropriate dimension of the array as indicated by the value of $sort. My question is this:
If I keep the results in an array, how can I pass the array when the user clicks on the hyperlink that tells which collumn to sort by? Do I need to use session variables? It doesn't seem like I can pass an array as a GET variable.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Sorting Table Results
I tried searching Google for some stuff about sorting table results. I want to be able to click the different headers and sort the results by each field. Anyone know some good sites/tutorials?
Sorting XML Results
The following code parses an XML file and displays the results. The function resultSort is meant to sort the results by price from highest to lowest. Unfortunately, it's not sorting correctly in all cases. I think this may be due to the prices being in euros. Right now, this is how it outputs the results: 1 208,00 2 148,00 412,00 638,00 942,00 This is how it should look: 2 148,00 1 208,00 942,00 638,00 412,00 Here's the code: PHP Code:
Sorting Results
I hava a table with a primary key cod_topico and I'd sort my results. I do this, ok? $query='SELECT * from topico order by cod_topico asc' ; But I would not sorting asc, How I sort a non-asc form? What is the oposite of asc?
Sorting Results
What I need to do is from the query I send sort the results by ID numbers from highest to lowest, because the highest number is the most recent news post I would like this to be printed first and then the lower the ID number the further down the post goes. Am I making sense? PHP Code:
Sorting Results By Header
What I am hoping to do is make the headers of the results column links, so that that when people click on them, the results on the page is automatically sorted alphabetically. I found a tutorial on http://codewalkers.com/tutorials/21/2.html, however it seems that I would need to make several changes to my code that would then make the other parts of my script unworkable (is that even a word!?). Here is my current search feature ; http://www.btinternet.com/~shahnawaz.khan/searchMD.htm . The headings I want to make sortable are Model, Creator and Book Title. PHP Code:
Sorting Results Of Odbc_exec?
I am running a PHP program that connects to an Access 2000 database via ODBC: $results = odbc_exec($connection_id, $sql_select); Is it possible to sort the contents of $results? I wish to use a regex-based sort order that you can't do in Access 2000* SQL
Sorting Results By Alphabet
I like to know how to sort and group results by alphabet. I have over 2800 flash games listed in my database and i want to grab the names and the id of each game, order them in alphabetical order then group them that way. So the results will show like this.. A A game A game 2 A game 3 B B game B game 2 B game 3 C C game C game 2 C game 3 What would the query be?
Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for. Can anyone help me get the Agreed? table's background color to the colors above? Code:
ODBC Results Sorting And Adding?
I need to go through ODBC results and add Quantity for like items. Quick example: Database Is: ItemQntyDate foo11-10-99 bar51-15-00 foo21-11-99 I need to somehow search through results and add matching Item Quantities together. In this example, the return I would expect is: ItemQntyDate bar51-15-00 foo31-10-99/1-11-99 because the foo Qnty added together became 3. Any thoughts on how to accomplish this? Load the ODBC results into an array and somehow sort through the array? Never done that before...
Sorting Database Query Results
I want to know if it is possible to sort query results so that the records with a value in a certain field is displayed first and the records with the field empty thereafter.
Sorting Query Results Into Groups
I have a 'staff' table with a column 'status', corresponding to a 'statuses' table with the appropriate titles (eg 1 | Editor in Chief). I want to display on the page the headings (the titles from statuses) along with all of the staff members with that status ID. I've attempted this using a query for each possible status, which I figure was pretty inefficient (plus it didn't work properly). The best I could do manually was to just display a list of staff and their statuses sorted in order of the title ranks.
Small Issue With Sorting Query Results.
In the below code I am simply trying to sort a list of results in the category "Drivers" by price. I can achieve this fine but it only seems to take the first 2 digits of the price when sorting, so... Instead of sorting like: €38 €70 €125 €175 €250 €370 Its sorts like: €125 €175 €250 €370 €38 €70 $limit = 'LIMIT ' .($pageno - 1) * $max .',' .$max; $query = "SELECT * FROM ads WHERE category = 'Drivers' AND validation = 0 ORDER BY '$price' $limit"; $result = mysqli_query($mysql_connect, $query) or die (mysqli_error($mysql_connect));
Retrieving,Sorting & Displaying Multiple Results From Mutliple Tables
I need to know how to run a php / mysql query to do the following. I have 1 database (lets call it "database" for now) within this database there are multiple tables ("News","Feature","Header_feature") For NEWS I need only the 6 latest results pulled from that table and displayed in a table. The "News" table has the following columns "ID","Title","Date","Body","Image" For Feature I need only 1 result retrieved from the database and displayed under the variable $ticker as it will display as a scrolling marquee within a table. The "Feature" table has the following columns "ID","Ticker". For Header_feature I need only 1 result retrieved from the database and displayed in the following manner <a href="$link"><img src"$header_feature">[/url] The "Header_feature table has the following columns "ID","image","link" How would I code this all into 1 page? I cant seem to get the query to do everything I want it to and display the results properly. You can see what I have so far at www.getlivemedia.com The $ticker is the scrolling text near the top of the page and the news is obviously the bulk of the page and $feature_image is the broken image.
Table Sorting Logic
I have a table with 4 columns. I have each column header acting as an asc/des sort on that column. I also have 4 filters that a user can apply to the table. What is supposed to happen.... If a user clicks on a column header twice in a row ( or 100 times in a row) the table will toggle back and forth between an asc/des sort on that column. If a user clicks on a "new" column header, the sort will reset to the initial asc/des value assigned to that column instead of just toggling from the current setting. If a user clicks on a filter, the results will be displayed with the "current" sorting method. What is actually happening.... Everything seems to be working fine except when a user clicks on the same filter link more than once. In that case, the sort toggles between asc /des, which I do not want to happen. PHP Code:
Problem Sorting By 2 Fields From Table
As part of a rating system on my site, data for the total rating and also the number of votes gets added into a table. I am currently trying to query this table to get the highest rated row of data. This worked fine when I only had "ORDER BY rating DESC LIMIT 1" at the end of my query - It would select the row where the rating was 5 out of 5. I realised that if 2 rows had the same rating, I could not determine which one to select. So i tried changing the code to: "ORDER BY rating, num_votes DESC LIMIT 1". For some reason, this now selects a row where both the rating and num_votes values are 0. Just in case you need to see the entire query, here it is:
Sorting A Table Into An Array In Mysql
Can someone tell me how to sort a table using a while function. This is what i want to do. I have table that has 17 fields, the first two are id and date and the rest of date..but what i want to do is take the data and sort it by the date and put the rest of the data under that date. example: date Data date Data I asume the array will look like this result[0][0] result[0][1] result[1][0] result[1][1] and so on .....
Sorting Variables
I have built a database of basketball statistics. I am only storing the most NECESSARY information. Example, I am not storing "points scored" because points scored = (field goals made * 2) + three-pointers made + free throws made. After doing a select query to get all of the data from the table, I create a variable called $ppg for points per game [((field goals made * 2) + three-pointers made + free throws made) / games]. I use "( $row = mysql_fetch_array($result))" and "extract($row);" to put the data into variables. The problem is I can't figure out how to sort by a variable. In order to make my top 10 scorers list, I have to "cheat" by ordering by "((field goals made * 2) + three-pointers made + free throws made) / games" in my sql query. I want to be able to order the data by the variable $ppg. Code:
Sorting Variables From Database
I have a function listed below, right now it sorts by $member_id I believe. I desire the same output ie.. member names, but I would like to sort it alphabetically by name. Is that possible? PHP Code:
Session Problem: Session Exists, But Session Variables Don't Lasts
I have some troubles with session variables. I can easily create a session, but the variable I append to global session array ( $_SESSION) lasts only until the end of current function. I prepared an example that can demonstrate the problem (see code bellow): The program flow is this: (1) It starts with "session_start()" and displays "login_form()". (2) When user enters his username and password, it goes to "login()" function which sets $_SESSION variables. (3) This function also "Echoes" session_id and user name to the screen. (4) Then it goes to "MyProgram()" function. It only "Echoes" the same variables to the screen. Strange is, that the session_id is the same in (3) and (4), but the user name ($_SESSION["username"]) is only in (3), but not in (4). By other words - $_SESSION["username"] variable filled up by "login()" function is immediately cleared. I don't know why. There must be something missing, but after 3 days of watching it, I can not find a problem here. =========================================== <? Function login($uzivatel, $heslo) { $_SESSION["username"] = $uzivatel; $_SESSION["pass"] = $heslo; $U_Name=$_SESSION['username']; echo "Login username: $U_Name<BR>"; echo "Login session ID: "; echo session_id(); echo "<BR>"; } Function login_form() { echo ("<DIV ALIGN='center'> <H1>Test</H1> <P>Please enter your username and password:</P> <form action='test.php' method='get'> <INPUT TYPE='HIDDEN' NAME='login' VALUE=TRUE> <TABLE BORDER=Ɔ'> <TR> <TD ALIGN='right'><U>U</U>ser name:</TD> <TD><INPUT NAME='uzivatel' SIZE=25 ACCESSKEY='U' TYPE='TEXT'></TD> </TR> <TR> <TD align='right'><U>P</U>assword:</TD> <TD><INPUT NAME='heslo' SIZE=25 ACCESSKEY='P' TYPE='PASSWORD'></TD> </TR> <TR> <TD COLSPAN=2 ALIGN='RIGHT'><INPUT NAME='OK' ACCESSKEY='O' TYPE='SUBMIT' VALUE='OK' TABINDEX=3></TD> </TR> </TABLE> </FORM></DIV></HTML>"); } Function MyProgram() { $U_Name=$_SESSION['username']; echo "Program username: $U_Name<BR>"; echo "Program session ID: "; echo session_id(); echo "<BR>"; } { session_start(); if ($_SESSION['username']): MyProgram(); else: { if (!$login): login_form(0); else: login($uzivatel, $heslo); MyProgram(); endif; } endif; } ?> ===========================================
Place The Results In Another Table
I am trying to take the results from a query and place the results in another table. I want to take all the results from $row join them together. is this possible to do? And can the results be stored with the information from the print statement? (<br> from each row) Code:
Colour Top 3 Results In A Table
I'm currently trying to make a poker league whats seem to be going well. I have populated a table with the league results, but would like 1st position in gold, 2nd in silver and 3rd in bronze. These will be the first three rows of the table, as the data has already been arranged in the correct order. I'm a little unsure how to go about doing this, and wondered if anyone could point me in the right direction. Code:
Sorting Sql Results In An Array Using Things Outside The Array To Sort Them?
I'm using PHP to connect to a database full of place names, and their associated post codes, latitude and longitude on the earth. A user types his or her post code into a form, plus a distance (in miles), and the script looks for other area codes (first half of the post code) within that distance. I can do that fine, but the results are ordered alphabetically by postcode, and I want to order it by the distance. Problem here, is that the distance isn't part of the array taken from the database, it takes the latitude and longitude of the area it's on in the while loop, and calculates the distance between the user's post code and that one, but it's not part of the array, so I can't sort the array using it. How can I sort it? Can I add the calculated distances to the array, and sort it using sort()? If yes, how do I add them to the array? Here's the page, just to explain better what the script does: http://navimaker.org/ed/owain/results.php?postcode=gl15&distance=34 Mess around with the postcode and distance vars. I'd put the source on here too but I'm doing all this over SSH and can't copy & paste very easily .
Dynamically Generated Results Table
I'm trying to write a script that dynamically generates HTML tables depending on the results from an SQL query. So far, I have managed to set the HTML table headers to be the same as those in the MySQL table. [thanks to rod k -cheers !] Now i'm trying to put the results in the table. Basically, I need a MySQL function to retrieve data and put it into the table until there is no data left.... (At the moment I am using "mysql_fetch_array()", but with this it is necessary to know the names of the columns to retrieve the information for each result set. Since my table is dynamic and should be able to build itself from different MySQL tables, the column names aren't fixed and so i can't use this to put the data in the tables...)
Creating A Link Within Table Results?
I am using php and mysql. Does anyone have any pointers on how to include links within table results that point to additional information also pulled from the same db table? I have some extensive info that I want to query. The intial results are going to be displayed in a simple wire frame html table layout. I would like each row to include a link that will take the reader to a more detailed version of the data for that particular row, and that more detailed data will of course come from the same db table. My problem is I don't know how to setup the code to create such link.
Display Query Results In A Table
$sql = "SELECT name FROM employee_tb; $result_query = @mysql_query ($sql);// run the query while ($row = mysql_fetch_array($result_query,MYSQL_NUM)){ $name = $row[0];} // assuming i have 8 results how can i display the results from this query in a table with 3 rows each column?
Displaying Array Results In Table
I'd like to display the results of an array in a table format with the Alias, Alias Destination & Username as column headings & the results underneath. PHP Code:
Putting Database Results In A 5x1 Table
I have a db of tens of thousands of entries. It's not too hard to pull all the entries and build a table that displays them one at a time, but in my case, that will be a huge waste of space. What I want to do is put one record in each of the columns. I thinks it's possible to do because I have seen very elaborate thumbnail gallery scripts to do this. I just want to be able to put two or three strings of text from each record into each row, and a checkbox. Here's sample of what I mean: <table width="76%" border="1" cellspacing="1" cellpadding="1"> <tr> <td>$record1Line1<br>$record1$Line2<br> <input type="checkbox" name="$record1checkbox" value="checkbox"></td> <td>$record2Line1<br>$record2$Line2<br> <input type="checkbox" name="$record2checkbox" value="checkbox"></td> <td>$record3Line1<br>$record3$Line2<br> <input type="checkbox" name="$record3checkbox" value="checkbox"></td> <td>$record4Line1<br>$record4$Line2<br> <input type="checkbox" name="$record3checkbox" value="checkbox"></td> <td>$record5Line1<br>$record5$Line2<br> <input type="checkbox" name="$record5checkbox" value="checkbox"></td> </tr> </table> I want to pull about 200 records at a time from the db and display as described above. How can I tell php to take five records from my result set and display above, then loop through the result set until I'm done?
JOIN Table Results W/MySQL
I have a query with a simple JOIN. For example: SELECT * FROM Companies INNER JOIN CompanyTypes ON Companies.CompanyID = CompanyTypes.CompanyID The query returns all fields from both Companies AND CompanyTypes. I would like all fields from Companies only.
Getting Data From A Table Based On The Results From Another?
This is the second part of my problems with a top ten list: I'm making a site for guitar effects. I'm trying to make a list of the top ten effects pedals, based on how many effects settings (patches) people have submitted for each pedal. There are two tables, pedals and patches: I want it to select patches and find out which "pedal_id" is most common, then select that pedal ID from pedals, echo some tuff, then do the query again, except search for the SECOND most popular value, echo it, then the third, echo it, etc etc etc
Display Results Of Survey In A Table.
Is it possible to have them fill in a survey with about 10 form fields, then display the results of everyone's survey in a table that can be sorted by different criteria so new users to the site can instantly see which one of our services is better for them.
Results From Two Db Tables Into One Html Table?
I have a query below that gets its results and puts them in a table. The current results are from two fields in a db table. I am wondering if it is possible to create a second query to get results from a different db table and echo them out in the same html table as the ones already there? Code:
Output Query Results To Html Table
I have a MySQL table "products" and I want to output product's data to html table as below: - A products contain 4 fields: image, name, description, price. - 4 products is nested in 1 html table 4 rows x 4 columns. Code:
Loop To Print Formatted Table From Sql Results
I'm trying to create a 3 column table now, and each cell will contain info from a single record. All the records will be pulled from a mysql database. What makes this a bit difficult is that I want the center column to be blank. Only the first and third columns will contain the results. I can't get the desired effect, and I'm not sure my loop logic is even correct. Does anyone know what's wrong with my code? Code:
Printing Mysql_fetch_array Results In Multicolumn Table
I'm not sure if this qualifies as a mysql or a php question so I'm asking in both groups. I am pulling the results of a mysql query from my database and want to print the results into a two column table. I know how to get the results into a single column table just fine using: while($row = mysql_fetch_array($result)) { print "<table border=2><tr><th>" . $row[name]; print "<tr><td>"; print mysql_field_name($result, 0) . ": " . $row[ID]."<br>"; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print mysql_field_name($result, 4) . ": " . $row[telephone]."<br>"; print "</td></tr>"; print "</table> "; print "<br><br>"; } and it works fine. But my efforts to get the reults into a two column setup have become frustrating. My latest attempt was: while($row = mysql_fetch_array($result)) { print "<table border=2 width=ྖ%'>"; print "<tr>"; print "<td>"; print "<b>" . $row[name] . "</b><br>"; print mysql_field_name($result, 0) . ": " . $row[ID]."<br>"; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print mysql_field_name($result, 4) . ": " . $row[telephone]."<br>"; print "</td>"; print "<td>"; print mysql_field_name($result, 0) . ": " . $row[ID]."<br>"; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print mysql_field_name($result, 4) . ": " . $row[telephone]."<br>"; print "</td>"; print "</tr>"; print "</table> "; print "<br><br>"; }
Formatting Mysql_fetch_array Results In HTML Table
This looks like a simple problem, but I just can't seem to wrap my head around it. I'm trying to build a table dynamically, based on a result set from mysql. There will be 9 results for a full page, with 3 table rows of 3 table cells. One result per cell. But all of the pages won't be full. Here's one of many ways I've tried to do it: <html> <head> <title>test</title> </head> <body> <table width="100%" border="1"> <?php include_once('db.inc.php'); $query = "SELECT DISTINCT title FROM mytable LIMIT 9"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $title = $row['title']; } for ($i = 0; $i < 3; $i++) { print ' <tr>' . " "; for ($e = 0; $e < 3; $e++) { print ' <td align="center">' . " ". ' title : ' . $title . " ". ' </td>' . " "; } print ' </tr>' . " "; } ?> </table> </body> </html> This prints out 3 rows of three like I hoped, but $title is the same in all 9 cells. I also have tried it with the for loops inside the while loop, which prints out 9 rows of 9 cells 9 times!
Getting Results To Display In Two Columns Of A HTML Table
How can i get the following script to display in two columns of a HTML table? At the moment i have it displaying in one column. If there are 5 results from the DB then the left HTML table column will display the 1st, 3rd and 5th result. The right HTML table column will display the 2nd and 4th results. Code:
Displaying SELECT Results In A Formatted Table
I was wondering how to show a table with a max limit of 20 results per page. I have various data being pulled and its putting it in a table, but its displayed all in one row. I want to format it so its a 4 column/5 row table. With that I then want the page to generate a numbered list at the bottom that calculates how many pages it takes to show 20 items on each. Code:
Displaying SQL Query Results In 3 Column Table
I would like to be able to display the results of an sql query in an html table, but the results need to be displayed in three columns, for example: Column 1 Column 2 Column 3 Result 1 Result 2 Result 3 Result 4 Result 5 Result 6 Result 7 Result 8 Result 9 I've tried to find the answers on the internet but i can't find anything that suits my needs!
Divide Mysql Results Into Rows In An Html Table
I need to divide my mySQL results into rows with 4 results on each row. Its for a small image gallery script, I wanna show 4 thumbnails per row. I have all the code ready to get the info and show it, I just need an example of how I can take the data from the table and have it automatically go to a new row every 4 entries.
Special Chars - Why Using GET Results In Trimmed Variables?
I'm trying to use GET method to pass variables through my script files. Unfortunately, when a special char (&, ?, +) is being posted the variable gets trimmed in a very strange way. I'm aware, that's connected with the way the GET method passes variable values, but I don't know how to make GET to take the variable value "as it is" without interpreting special chars as special chars. So, how should I send GET variables in order not to get them trimmed when they contain special chars?
Passing Variables And Session Variables
I'm currently working on a shopping cart script that works just fine with register_globals turned on but when turned off i get all kind of errors. The following page displays a detail of the book with the "Add to cart" link at the bottom. PHP Code:
Variables That Change Session Variables
I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between pages, then the final data is passed to a calculation script. However, I've noticed that if I assign a session variable to another variable, which then performs a mathematical calculation, the session variable changes. i.e. $_SESSION["inflation"] = 4; $temp_inf = $_SESSION["inflation"]; if ($_SESSION["inflation"] =="RPI") { $inflation = $rpi;} else {$inflation = ($temp_inf/100.0);} now it equals = 0.04 How can I take a value from a session and perform operations on it without altering the original session value.
Form Variables To Session Variables
I am writing a small script that consists of two pages: page one displays a bunch of values from a DB (ie. First Name, Last Name, Phone Number). On this page you will find a form that follows this format: <input type="text" name="edit_firstname" size="20" maxlength="35" value='Bob'> <input type="text" name="edit_lastname" size="20" maxlength="35" value='Smith'> <input type="text" name="edit_phone" size="20" maxlength="35" value='5552222'> So when you see the page there will already be a 'default' value in each line (which is information extracted from a DB). This works perfectly and has been tested thoroughly. On the second page I have the following code: $editfirstname = $_POST['edit_firstname']; $editlastname = $_POST['edit_lastname']; $editphone = $_POST['edit_phone']; What I am trying to do is this: the default value for edit_firstname from the form is 'Bob' by default, but the user can change this in the input field on the first page. This value, whether changed or unchanged, should then be stored as edit_firstname and by calling up the function $_POST[''] on the second page I want to transfer the value to the variable $editfirstname. However, it seems that $_POST['edit_firstname'] and the other fields do not return a value at all, hence $editfirstname = '' or $editfirstname = 'NULL'. I have never tried to do things this way before.
Curl: Posting Form Variables Results In Redirection
I'm using the curl functions in php to scrape the wan ip address from my home router (the router is an SMC product). This is a two step process: 1. post the password value to the login.htm page 2. capture and parse the content from the status_main.htm page On the SMC's login.htm page there is a form with the following elements: <form name=tF method=post action=login.htm> <input type=password name=pws> <input type=hidden name=page value=login> <submit value='LOGIN'> Here are three test cases - only the first two work as expected. I need to understand why I got that third response... posting the variables causes a the SMC to give me a redirection to index.htm which does not exist? COMMAND LINE TEST (returns login.htm and status_main.htm accurately): curl -d page=login.htm -d pws=mypassword http://10.10.10.1/login.htm curl http://10.10.10.1/status_main.htm | grep 'wan_ip' PHP NO-POST TEST(returns login.htm accurately): $ch = curl_init("http://10.10.10.1/login.htm"); $strIP = curl_exec($ch); curl_close($ch); PHP POST TEST (returns an unexpected result): $ch = curl_init("http://10.10.10.1/login.htm"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "page=login&pws=mypassword"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $strIP = curl_exec($ch); curl_close($ch); print "<!-- $strIP -->"; <!-- <html><head><meta http-equiv=refresh content=Ɔ url=/index.htm'></head></html> -->
Sort Search Results - Query Made From Form Variables
I have created a search engine with multiple search fields, the results.php page shows the results. My question is, how can I allow the user to sort the results (name, description, price etc), simply by clicking on the column title. This wouldn't be a problem if the SELECT query was constant - just add a $var at the end where ORDER BY should be, but how can I do this when the SELECT statement is made up of $_POST VARS? Surely if I reload the page with the sort command, it will have forgotten the $_POST vars that made up the query? I have searched EVERYWHERE for help on this PHP Code:
PHP Variables From Mysql Table
I have a PHP script which parces a mySQL table and shows which sections meet on which day by using an array containing (mon,...Fri) and another lisitng sections. I then have the PHP do to selecrt statements on to list those sections that are mixed and those that are not. I have a title "Open to Boys and Girls" then it cycles through the applicable groups. I want to hide this title if there are no group from the mysql search but can't figure out how as the actual varaible $result is set once the search is done even if it pulls nothing back Code is below, CODE ------------------------------------------- $result = @mysql_query("SELECT Group_Name FROM `groups` where ".$section."_comment like '%".$day."%' and ".$section."_comment like '%mixed%'"); echo "<u>Open to Boys & Girls</u></br>"; while($row = mysql_fetch_array( $result )) { $Group_Name = $row['Group_Name']; echo "• ".$Group_Name."</br>"; }// end Group Name loop mixed
Using Variables At Table Names
Do you guys know how to use PHP variables as table names? I'm trying to create a function that can be used by several pages. PHP Code:
|