PHP - No Results Are Returned To The Table
Hi guys,
I am working with an old script at the moment, there is one page which just will not populate the table results. I have tried running multiple debugging commands but the only one it flags is the line displaying Quote last; saying it's not a used function. If I comment out this line, no errors are produced but the results do not enter the table. Can anyone shed some light on this please, I've spent hours and hours and banging my head against a brick wall would probably be more constructive right now. Many thanks indeed for any help or advice. <?php mysql_connect("localhost", "$db_user","$db_upwd") or die ("Error - Could not connect: " . mysql_error()); mysql_select_db("$database"); $query="select host,count(*) from badc_mis_prog group by host"; $result = mysql_query($query) or die ("Error - Query: $query" . mysql_error()); $count=0; $hosts=array(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $html_hlname=$row[0]; $html_hlname=preg_replace("/</","<",$html_hlname); $html_hlname=preg_replace("/>/",">",$html_hlname); array_push($hosts, $html_hlname,$row[1],0); $count++; } $query="select host,count(*) from badc_mis_prog where reported=1 group by host"; $result = mysql_query($query) or die ("Error - Query: $query" . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $html_hlname=$row[0]; $html_hlname=preg_replace("/</","<",$html_hlname); $html_hlname=preg_replace("/>/",">",$html_hlname); for ($i=0; $i<($count*3); $i+=3) { if ($hosts[$i] == $html_hlname) { $hosts[($i+2)]=$row[1]; last; } } } for ($i=0 ; $i<(($count-1)*3); $i+=3){ for ($j=$i+3 ; $j<($count*3); $j+=3){ if ($hosts[($i+1)] < $hosts[($j+1)]){ $temp=array(); $temp[0]=$hosts[$i]; $temp[1]=$hosts[($i+1)]; $temp[2]=$hosts[($i+2)]; $hosts[$i]=$hosts[$j]; $hosts[($i+1)]=$hosts[($j+1)]; $hosts[($i+2)]=$hosts[($j+2)]; $hosts[$j]=$temp[0]; $hosts[($j+1)]=$temp[1]; $hosts[($j+2)]=$temp[2]; } } } print "<br><br><br><center><table border=\"1\">\n"; print "<tr><td>Host Name</td><td>Hosted</td><td>Reported</td><td>Ratio H/R</td></tr>\n"; for ($i=0; $i<($count*3); $i+=3) { if ($hosts[($i+1)]<15){ break;} printf ("<tr><td> %s </td><td> %d </td><td> %d </td><td>%.1f %%</td></tr>\n",$hosts[$i],$hosts[($i+1)],$hosts[($i+2)],(($hosts[($i+2)]/$hosts[($i+1)])*100)); } print "</table></center>\n"; ?> Similar TutorialsGreetings! This n00b has a "search engine" dedicated to extracting relevant information from log files. It works by parsing preset fields in the log filename. I'd like to have some notification when the search returns no rows as I am planning to add more search options. Here's my code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <title>LogFile Search</title> <style type="text/css"> <<irrelevant stuff removed>> </style> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" language="javascript" src="js/UI.js"></script> </head> <body> <h3 id="myh3">Log File Search</h3><h5>Version 1.0.1</h5> <h4 id="myh4"><ul><li> <<irrelevant stuff removed>> </li></ul></h4> <form method="post" name="LogFile_Search" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table id="mytable"> <tbody> <tr> <td id="mytd">Result(P|F|N): <input type="text" id="Result_PFN" name="Result_PFN" size="31"/></td> <td id="mytd">Script Version: <input type="text" id="ScriptVersion" name="ScriptVersion" size="31"/></td> </tr> </tbody> </table> <br> <input type="submit" value="Search" onclick="doForm();"> <input type="button" value="Reset" onclick="resetForm();"> </form> <div id="searchResult"> <?php /* Where the logs files are dropped by external process. */ $mydir = $_SERVER['DOCUMENT_ROOT'] . "/LogFile_Search/LogFiles"; /* Handle to directory. */ $dir = opendir($mydir); /* Form variables. */ $Result_PFN = $_POST['Result_PFN']; $ScriptVersion = $_POST['ScriptVersion']; /* Test each field -- triggers JS alert if all are empty. */ if (!empty($Result_PFN)) { doResult_PFN(); } elseif (!empty($ScriptVersion)) { doScriptVersion(); } /* Function for Search on Script version in logfile contents. */ function doScriptVersion() { global $dir; global $mydir; global $ScriptVersion; echo '<table id=\'mytable\'><tbody><tr><td id=\'mytd\'>Log File Name.</td></tr>'; //grabs all log files matching the script version number that's input in the form. $cmd = "find " . $mydir . " -type f -print0 | xargs -0 grep -e 'Test_Version=" . $ScriptVersion . "'"; exec($cmd, $output); //Sort the array using a case insensitive "natural order" algorithm. natcasesort($output); if (count($output) > 0) { foreach ($output as $v) { //Display file name without full path as URL. echo '<tr><td><a href="' . basename($mydir) . '/' . array_pop(explode("/", array_shift(explode(":", $v)))) . '" target="_blank">' . array_pop(explode("/", array_shift(explode(":", $v)))) . '</a></td></tr>'; } } else { echo "<html><body style=\"background-color:#0080c0\"> <script type=\"text/javascript\" language=\"javascript\">alert( 'Nothing found' + '.');</script> </body></html>"; } closedir($dir); echo "</table></body>"; } /* Function for Search on Result marker in file name. */ function doResult_PFN() { global $dir; global $mydir; global $Result_PFN; echo '<table id=\'mytable\'><tbody><tr><td id=\'mytd\'>Log File Name.</td></tr>'; if ($dir) { //List files in directory while (($file = readdir($dir)) !== false) //Ignores OS stuff. if ($file != "." && $file != "..") { //Pattern match for result. if (preg_match("/~(P|F|N)*" . $Result_PFN . "~/i", $file)) { //Sort the array using a case insensitive "natural order" algorithm. natcasesort($file); echo '<tr><td><a href="' . basename($mydir) . '/' . $file . '" target="_blank">' . $file . '</a></td></tr>'; } } else { echo "<html><body style=\"background-color:#0080c0\"> <script type=\"text/javascript\" language=\"javascript\">alert( 'Nothing found' + '.');</script> </body></html>"; } closedir($dir); } echo "</table></body>"; } ?> </div> </body> </html> When doResult_PFN() returns no result, the ELSE portion is never evaluated and no notification is sent to the user. However, I have no problem with doScriptVersion(): it returns an alert. What am I missing? Thanks, Al. Hello. I am interested in taking a result returned from a database and having it displayed in a certain way/style on the user's screen; For example, the user enters text into a field and hits "submit" - the data is saved in the database then displayed to the user (This part I have working just fine so far due to help I received here.) My question is if I would like to, for example, have said text not simply dumped to the top of the screen, inline, but nicely formatted in a boxed, text area, I assume I will use HTML/CSS, and I was wondering if anyone had any good links/tutorials regarding this topic so I may look further into it (my search thus far has not turned up the correct topic or results). Thank-you in advance for any assistance. ~Matty Search not functioning. The drop down box to search on Club_Name and Email is blank, clicking search results unchanged ... all suggestions appreciated ... newbie at php. Thanks. <!-- Code below is not functional, trying to query search results, search box with drop down box for two fields--> <table width="50%"> <tr> <td height="30" align="left" bgcolor="#FFFFFF" class="form1" > {$letter_links} </td> <td height="30" align="right" bgcolor="#FFFFFF" class="form1" > <input type=hidden name="sorter" value="{$sorter}"> <table><tr> <form name="search_form" action="{$form.action}" method="post"> <td class="form1" ><input type="text" name="search" value="{$search}"></td> <td class="form1" ><select name="s_type" style=""> {section name=s loop=$types} <option value="{$smarty.section.s.index_next}" {if $types .sel}selected{/if}>{$types .value}</option> {/section} </select></td> <td class="form1"><input type="button" value="{$button.search}" class="button" onclick="javascript: document.search_form.submit();" name="search_submit"></td> </form> </tr></table> </td> </tr> </table> <!-- Code below successfully displays query results --> <form method="post" action="{$file_name}?sel=approve" enctype="multipart/form-data" name="form1" onsubmit="foo(); return false;"> <table cellspacing="2" cellpadding="10" border="1"> <tr align="center"><td>Num</td><td>Club Name</td><td>Login</td><td>Country</td><td>Region</td><td>City</td><td>Address</td><td>Web site</td><td>Email</td><td>Contact Name</td><td>Contact Phone</td><td>Swinging</td><td>Alcohol</td><td>Food</td><td>Entertainment</td><td>Fees</td><td>Approved/<br/>Rejected</td><td>Actions</td></tr> {foreach item=item from=$contest key=key name=foo} <tr align="center"><td><input type="hidden" name="all_approves[{$item.id}]" value="{$item.id}"/>{$key+1}</td><td>{$item.name}</td><td>{$item.login}</td><td>{$item.country_name}</td><td>{$item.region_name}</td><td>{$item.city_name}</td><td>{$item.address}</td><td>{$item.web_site}</td><td>{$item.email}</td><td>{$item.contact_name}</td><td>{$item.contact_phone}</td> <td> {math equation="x - 1" x=$item.swinging assign=index_pos} {$xml_swing[$index_pos].value}</td> <td>{math equation="x - 1" x=$item.alcohol assign=index_pos}{$xml_alco[$index_pos].value}</td> <td>{math equation="x - 1" x=$item.foot assign=index_pos}{$xml_foot[$index_pos].value}</td> <td>{math equation="x - 1" x=$item.entertainment assign=index_pos}{$xml_entertainment[$index_pos].value}</td> <td>{math equation="x - 1" x=$item.fees assign=index_pos}{$xml_fees[$index_pos].value}</td><td> <span> {if $item.is_approved eq '1'} Approved {else} Rejected {/if}</span></td><td align="center"><a href="{$file_name}?sel=edit&id_content={$item.id}">[ Edit ]</a><br/><a href="{$file_name}?sel=delete&id_content={$item.id}">[ Delete ]</a><br/><a href="{$file_name}?sel=approve&id_content={$item.id}">[ Approve ]</a><br/><a href="{$file_name}?sel=reject&id_content={$item.id}">[ Reject ]</a></tr> {/foreach} </table> </form> I am looking to accomplish the following but have been hitting a brick wall: * User enters a single keyword into a text field, and conducts a search keyword search. * The results are pulled from the campusbooks.com API(API docs attached) * result are then output in <div> class and includes all the book details and its corresponding url./img etc I'm trying to simplify this process but I continue to receive syntax errors. A step by step practical explanation would do me justice! I've had a bit of a search around to see if this is possible but have yet to find something. I'm looking to be able to offset the results from opendir or similar function without returning all the files/folders. In other words i'd like to display the file/folder results over multiple pages when there are a lot of files/folders to display. Is this at all possible? here is my code... please help <form method="get" action="shit3.php"> <input maxlength="50" size="50" type="text" name="q"> <input type="submit" value="SEARCH"> </form> <?php if (@$_GET['q']) { $var = $_GET['q'] ; $trimmed = trim($var); $limit=1; if ($trimmed == "") { echo "Please enter a search..."; exit; } if (!isset($var)) { echo "Container not found!"; exit; } mysql_connect("localhost", "xxx", "yyy") or die(mysql_error()); mysql_query("SET NAMES 'cp1251'"); mysql_select_db("agaexpor_container") or die("Unable to select database"); //select which database we're using $query = "select * from containertracking where vin like \"%$trimmed%\" order by vin"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); if (empty($s)) { $s=0; } $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); $count = 1 + $s ; while ($row= mysql_fetch_array($result)) { $vin = $row["vin"]; $container = $row["container"]; echo "$count.) VIN: $vin <br />"; echo "container is: $container <br />"; $count++ ; } } ?> I'm hoping this is a simple question. When I use the code below, my twitter search query appears in BOLD within the returned results. I would like to style the search term differently. I can use CSS to style the avatar, author, and other information within the returned results etc, but I can't figure out how to style the search term ($q) within the returned twitter information. Any help would be much appreciated. <?php class twitter_class { function twitter_class() { $this->realNamePattern = '/\((.*?)\)/'; $this->searchURL = 'http://search.twitter.com/search.atom?lang=en&q='; $this->intervalNames = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year'); $this->intervalSeconds = array( 1, 60, 3600, 86400, 604800, 2630880, 31570560); $this->badWords = array('somebadword', 'anotherbadword'); } function getTweets($q, $limit=15) { $output = ''; // get the search result $ch= curl_init($this->searchURL . urlencode($q)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); $response = curl_exec($ch); if ($response !== FALSE) { $xml = simplexml_load_string($response); $output = ''; $tweets = 0; for($i=0; $i<count($xml->entry); $i++) { $crtEntry = $xml->entry[$i]; $account = $crtEntry->author->uri; $image = $crtEntry->link[1]->attributes()->href; $tweet = $crtEntry->content; // skip tweets containing banned words $foundBadWord = false; foreach ($this->badWords as $badWord) { if(stristr($tweet, $badWord) !== FALSE) { $foundBadWord = true; break; } } $tweet = str_replace('<a href=', '<a target="_blank" href=', $tweet); // skip this tweet containing a banned word if ($foundBadWord) continue; // don't process any more tweets if at the limit if ($tweets==$limit) break; $tweets++; // name is in this format "acountname (Real Name)" preg_match($this->realNamePattern, $crtEntry->author->name, $matches); $name = $matches[1]; // get the time passed between now and the time of tweet, don't allow for negative // (future) values that may have occured if server time is wrong $time = 'just now'; $secondsPassed = time() - strtotime($crtEntry->published); if ($secondsPassed>0) { // see what interval are we in for($j = count($this->intervalSeconds)-1; ($j >= 0); $j--) { $crtIntervalName = $this->intervalNames[$j]; $crtInterval = $this->intervalSeconds[$j]; if ($secondsPassed >= $crtInterval) { $value = floor($secondsPassed / $crtInterval); if ($value > 1) $crtIntervalName .= 's'; $time = $value . ' ' . $crtIntervalName . ' ago'; break; } } } $output .= ' <div class="tweet"> <div class="avatar"> <a href="' . $account . '" target="_blank"><img src="' . $image .'"></a> </div> <div class="message"> <span class="author"><a href="' . $account . '" target="_blank">' . $name . '</a></span>: ' . $tweet . '<span class="time"> - ' . $time . '</span> </div> </div>'; } } else $output = '<div class="tweet"><span class="error">' . curl_error($ch) . '</span></div>'; curl_close($ch); return $output; } } ?> The HTML I have been using with this code is here Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Twitter</title> </head> <body> <?php require('twitter.class.php'); $twitter = new twitter_class(); echo $twitter->getTweets('example search term', 10); ?> </body> </html> This is not my code. It is from a tutorial that can be accessed from here >> http://www.richnetapps.com/php-twitter-search-parser/ when I do a "SELECT * FROM system_disks WHERE system_id = 'aNumber'" and their is more than one result with that system_id, I get more than one result obviously. I essentially need two results in one row. I've took a screen shot of what it is doing and what I need it to do. The blurred row is a different system_id This is what the while ($row = mysql_fetch_array($query)) is currently doing: This is what I would like it to do: Sorry if this is a dumb question, I've been coding the past 48 hours and my brain is fried i think this is more of a HTML problem, but it is in my PHP code so i will ask anyway! if i have the search code: if (count($error) < 1) { $searchSQL = "SELECT id, placing, racedate, horseid FROM race WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['placing'])?"`placing` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['racedate'])?"`racedate` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['horseid'])?"`horseid` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`placing` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " GROUP BY `horseid` ORDER BY `racedate`"; // order by title. $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; echo '<table border="1"><tr><th>Num</th><th>Placing</th><th>Race Date</th><th>Horse ID</th></tr>'; while ($row = mysql_fetch_assoc($searchResult)) { echo "<tr><td>$i</td> <td>{$row['placing']}</td> <td><a href=\"viewrace.php?date=" . urlencode($row['racedate']) . "\">{$row['racedate']}</a></td> <td>{$row['horseid']}</td></tr>"; $i++; } echo '</table>'; how do i get the 'horseid' to appear at the header of the table rather than in a column? thank you for all the brilliant help this site provides!! Hi I have the following code: Code: [Select] $result = mysql_query("SELECT * FROM xbox_games order by gameid"); $row = mysql_fetch_assoc($result); $id = $row["gameid"]; $title = $row["gametitle"]; $cover = $row["cover"]; <?php echo $title;?> Which displays only the first result from my database. How can i change this to display all the results either as a list, or in a table? Thanks I have three tables: events, orderdetails & orders. First I query orderdetails to find all the records that match the EventID: $query1 = SELECT * FROM orderdetails WHERE EventID = $_SESSION['EventID']; This returns 4 records. These 4 records have a field called DetailOrderID which is the foreign key for orders.OrderID. Next I need to query the results of the first query to find all the records in the orders table that match up. For example: SELECT * from orders where $query1.DetailOrderID = orders.OrderID. How would I go about doing this? I'm head down the temporary table solution but wanted to through this one out for discussion before I invest too much time. Does anybody know how to show the below php results in a table format? <?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ $fname = $_POST['fname']; $lname = $_POST['lname']; $skill = $_POST['skill']; //connect to the database $db=mysql_connect ("127.0.0.1", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //select the database to use $mydb=mysql_select_db("resource matrix"); //query the database table $sql="SELECT DISTINCT First_Name, Last_Name, l.Resource_ID FROM ((resource l inner join resource_skill ln on l.Resource_ID = ln.Resource_ID) inner join skill n on ln.Skill_ID = n.Skill_ID) WHERE First_Name LIKE '$fname' OR Last_Name LIKE '$lname' OR Skill_Name LIKE '$skill'"; //run the query against the mysql query function $result=mysql_query($sql); //create while loop and loop through result set while($row=mysql_fetch_array($result)){ $First_Name =$row['First_Name']; $Last_Name=$row['Last_Name']; $Resource_ID=$row['Resource_ID']; //display the result of the array echo "<ul>\n"; echo "<li>" . "<a href=\"a.php?id=$Resource_ID\">" .$First_Name . " " . $Last_Name . "</a></li>\n"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } My db is called localDB, and the table in that db is called MonthlySales. I want to display the table in a table in php. But to be able to filter the table by the column year, so if 2000 is selected only the values with 2000 are shown. Is there also a better way to populate the drop down menu? My script looks like: Code: [Select] <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form_filter' > <select name="value"> <option value="all">All</option> <option value="2000">2000</option> <option value="2001">2001</option> </select> <input type='submit' value = 'Filter'> </form> <?php $link = mysql_connect('localhost', 'root', 'root'); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db('localDB', $link); if (!$db_selected) { die (mysql_error()); } // process form when posted if(isset($_POST['value'])) { if($_POST['value'] == '2000') { $query = "SELECT * FROM MonthlySales WHERE Year='2000'"; } elseif($_POST['value'] == '2001') { $query = "SELECT * FROM MonthlySales WHERE Year='2001'"; } else { $query = "SELECT * FROM MonthlySales"; } $sql = mysql_query($query); while ($row = mysql_fetch_array($query)) { $Id = $row["Id"]; $ProductCode = $row["ProductCode"]; $Month = $row["Month"]; $Year = $row["Year"]; $SalesVolume = $row["SalesVolume"]; echo "<tr>"; echo "<td>" . $row['Id'] . "</td>"; echo "<td>" . $row['ProductCode'] . "</td>"; echo "<td>" . $row['Month'] . "</td>"; echo "<td>" . $row['Year'] . "</td>"; echo "<td>" . $row['SalesVoulme'] . "</td>"; echo "</tr>"; } mysql_close($con); } ?> Hi, I'm quite new to this and I'm trying to get this to line up in a table with 3 columns (unlimited rows) I have searched and tried but I'm not having any luck. Can any one help? Thank you Code: [Select] <?php echo '<div class="resultados_sub_cat">'; foreach($this->subcats as $key => $subcat) { $subcat->link = JRoute::_('index.php?option=classcliff&view=list&catid='.$subcat->id."&Itemid=".$this->Itemid); if ($key != 0) echo ' - '; echo '<a href="'.$subcat->link.'">'.$subcat->name.'</a>'; } ?> Ive gotten some results user selcts check box on first page The php page will say which brackets it falls between example price is between 100-300 say I dont seem to be able to populate a table with the data in the database:S Code: [Select] $row_number= 0; while ($row = mysql_fetch_array($result3)) { If (($row["price"] = $price_low) && ($row["price"] <= $price_high)) //price If (($row["storage"] = $storage_low) && ($row["storage"] <= $storage_high)) //storage if (($row["Processor "] = $processor_low) && ($row["Processor"] <= $processor_high)) //Processor { $row_number++; ?> <tr> <td align="center"><?php print $row["Computer_Price"]; ?> </td> <td align="center"><?php print $row["Computer_Storage"]; ?> </td> <td align="center"><?php print $row["Computer_ProcessorSpeed"]; ?> </td> </tr> </table> Thats wat im usign atm the price_low and price_high are what sets the low and high price for the search How would I force a certain table format and then populate it with the SQL results in their respective columns and rows? i.e. Code: [Select] +------------------+----------+----------+----------+ | | Col 1 | Col 2 | Col 3 | +-------------------+----------+----------+----------+ | row 1 lab data | 16777216 | | 573 | +-------------------+----------+----------+----------+ | row 2 lab data | 23454235 | 87247247 | 65743 | +-------------------+----------+----------+----------+ | row 3 lab data | 16777216 | 47832364 | | +-------------------+----------+----------+----------+ Currently I'm just using a while loop to populate it horizontally, but that doesn't work for row 1. Code: [Select] <?PHP while($row = mysql_fetch_array($result) { ?> blah blah blah html here <?PHP echo $row[0]; ?> more html <?PHP echo $row[1]; ?> and so forth <?PHP } ?> It ends up producing this: Code: [Select] +------------------+----------+----------+----------+ | | Col 1 | Col 2 | Col 3 | +-------------------+----------+----------+----------+ | row 1 lab data | 16777216 | 573 | | +-------------------+----------+----------+----------+ | row 2 lab data | 23454235 | 87247247 | 65743 | +-------------------+----------+----------+----------+ | row 3 lab data | 16777216 | 47832364 | | +-------------------+----------+----------+----------+ Hello everyone !
I am currently developing a module for my site that will allow me to classify each solution to help a disability by type. Type : Visual disability Solution : Add screen readers For this, I have a database in which these types and solutions are found. In this database, the solutions of one type or another are not in a defined order. They can be put randomly, when a user adds one. I need to display, in a table, these Types first (as a title), then the solutions corresponding to this type. I manage to generate a display thanks to a foreach loop, but my solutions are all mixed up and therefore not clearly sorted.
Visual disability Audio-described cut-scenes Highlighted path to follow Sensitivity settings for all the controls Screen readers on menus Slow down the game speed But I would need it to look like this: Visual disability Audio-described cut-scenes Highlighted path to follow Screen readers on menus Slow down the game speed Physical disability Sensitivity settings for all the controls In my example above, only the solution "Sensitivity settings for all the controls" is part of the "Physical disability" type. The rest is part of the "Visual disability" type. Here is the code I currently use to retrieve my information from my database and display it. It's a Wordpress.
/*====== Accessibility Options ======*/ function cloux_accessibility_options() { if ( function_exists( 'rwmb_meta' ) ) { $output = ""; $accessibility_options = rwmb_meta( 'accessibility-options' ); $accessibility_options_status = rwmb_meta( 'accessibility-options-status' ); if( $accessibility_options_status == "1" ) { if( !empty( $accessibility_options ) ) { $output .= '<div class="accessibility-options widget-box">'; $output .= cloux_title( $title = esc_html__( 'Accessibility Options', 'cloux' ), $style = "style-4", $align = "left", $colored_title = '' ); $output .= '<ul>'; $output .= '<li class="title visual_disability">' . esc_html__( 'Visual disability', 'cloux' ) . '</li>'; $output .= '</ul>'; foreach ( $accessibility_options as $accessibility_options ) { if( !empty( $accessibility_options ) ) { $accessibility_name = isset( $accessibility_options['accessibility-options-name'] ) ? $accessibility_options['accessibility-options-name'] : ''; $accessibility_type = isset( $accessibility_options['accessibility-type-name'] ) ? $accessibility_options['accessibility-type-name'] : ''; $accessibility_type = get_term( $accessibility_type, 'accessibility' ); $accessibility_type_name = $accessibility_type->name; $availability = isset( $accessibility_options['availability'] ) ? $accessibility_options['availability'] : ''; if ( $accessibility_type_name == "Visual disability" ){ if( !empty( $accessibility_name ) or !empty( $availability )) { $output .= '<ul>'; $output .= '<li class="item accessibility_name">'; if( !empty( $accessibility_name ) ) { $accessibility_name = get_term( $accessibility_name, 'accessibility' ); if( ( !empty( $accessibility_name ) ) ) { $output .= '<a href="' . get_term_link( $accessibility_name ) . '">' . esc_attr( $accessibility_name->name ) . '</a>'; } } $output .= '</li>'; $output .= '<li class="item visual_disability status">'; if( $availability == "1" ) { $output .= '<i class="fas fa-check" aria-hidden="true"></i>'; } else { $output .= '<i class="fas fa-times" aria-hidden="true"></i>'; } $output .= '</li>'; } } if ( $accessibility_type_name == "Motor/Physical disability" ){ if( !empty( $accessibility_name ) or !empty( $availability )) { $output .= '<ul>'; $output .= '<li class="item accessibility_name">'; if( !empty( $accessibility_name ) ) { $accessibility_name = get_term( $accessibility_name, 'accessibility' ); if( ( !empty( $accessibility_name ) ) ) { $output .= '<a href="' . get_term_link( $accessibility_name ) . '">' . esc_attr( $accessibility_name->name ) . '</a>'; } } $output .= '</li>'; $output .= '<li class="item visual_disability status">'; if( $availability == "1" ) { $output .= '<i class="fas fa-check" aria-hidden="true"></i>'; } else { $output .= '<i class="fas fa-times" aria-hidden="true"></i>'; } $output .= '</li>'; } } $output .= '</ul>'; } } $output .= '</div>'; } } return $output; } } Thank you in advance for all the help you can give me! Edited January 13 by Sagaroth I have been trying to work out how to get my results into a 3 column layout using css and not using tables in any way. I found the code for tables: echo '<table>'; $counter = 0; $cells_per_row = 3; while($row=mysql_fetch_array($result)) { $counter++; if(($counter % $cells_per_row) == 1) { echo '<tr>'; } echo '<td>' . (whatever you echo from your $row array) . '</td>'; if(($counter % $cells_per_row) == 0) { echo '</tr>'; } } // just in case we haven't closed the last row // this would happen if our result set isn't divisible by $cells_per_row if(($counter % $cells_per_row) != 0) { echo '</tr>'; } echo '</table>'; How Can I adapt this or how should I use divs here? I am fine with the css code, just need to work out how to get the 3 column layout correct in the loop. Hi Guys. I have some code which displays the rows of a database table in a html table on my webpage: Code: [Select] <?php//to display image from source$dir = "360_covers";echo '<table>';echo '<tr><th>Title</th><th>Cover</th><th>comment</th></tr>';$result = mysql_query("SELECT * FROM xbox_games order by gametitle");while ($row = mysql_fetch_assoc($result)) { echo "<tr><td>{$row['gametitle']}</td><td><img src=\"$dir/{$row['cover']}\" width='38' height='38'></td><td>{$row['cover']}</td></tr>";}//close out tableecho '</table>';?> What i want to do now is add a form, possibly at the end of each row of the html table, which will allow a session user to update that record. Can anybody advise on the best way to do this? |