PHP - How To Add Text To A Null Result In A Table
Hi, I have results from a MySQL table column which does an echo into a table cell, but some of the results from the table column is be empty, so is there a way to fill in the blanks with text like "No data"?
Similar Tutorialshi all, i have a script in where the user enters there post code and it will provide a price for delivery, how would i echo "please contact us for price" if the db record for the price is (null) or empty?? <?php mysql_connect ("localhost", "root","password") or die (mysql_error()); mysql_select_db ("postcode"); $term = $_POST['term']; $sql = mysql_query("SELECT * FROM uk_postcodes, zones WHERE postcode LIKE '%$term%' AND zone_id = zone_large "); while ($row = mysql_fetch_array($sql)){ echo '<br/> Postcode: '.$row['postcode']; echo '<br/> Town: '.$row['town']; echo '<br/> County: '.$row['county']; echo '<br/> Small: £'.$row['price_s']; echo '<br/> Medium: £'.$row['price_m']; echo '<br/> Large: £'.$row['price_l']; echo '<br/><br/>'; } ?> Need some help finding out why this is returning a null result set:
The below code is giving me a result set of an integer set to "0" (the id), a "word"and "def" both set to NULL. It's failing at my "Error #2" point. var_dumps on $id, $word, and $def all give the null output. Each $category is being shown when I var_dump($category).
I know this shouldn't be the case because when I run this straight in PHPMyAdmin I get a non-null result set.
(Not sure why my indentation is not carrying over to the forum. Sorry about that.)
<?php session_start(); if(!isset($_SESSION['loopcatch']) || $_SESSION['loopcatch']==null || !is_int($_SESSION['loopcatch'])){ $_SESSION['loopcatch']=0; } if($_SESSION['loopCatch'] > 1){ //Email error die(); } require 'dbConnect.php'; $categories=array('business', 'music', 'film', 'drum'); //Pull Quotes //Query to Pull random quote $mainQuery="SELECT `r1`.`id`, `r1`.`word`, `r1`.`def` FROM `dictionary` AS `r1` JOIN (SELECT (RAND() * (SELECT MAX(`id`) FROM `dictionary`)) AS `id`) AS `r2` WHERE `r1`.`id` >= `r2`.`id` AND `category`=? AND `checked`=0 ORDER BY `r1`.`id` ASC LIMIT 1"; //prepare quotes query if($prepareQuote=mysqli_prepare($conn, $mainQuery)){ //filter through each category foreach($categories as $category){ //Bind the variable to the quotes query mysqli_stmt_bind_param($prepareQuote, "s", $category); //execute quotes statement mysqli_stmt_execute($prepareQuote); //Store quotes result set mysqli_stmt_store_result($prepareQuote); //Check how many rows are returned if(mysqli_stmt_num_rows($prepareQuote) > 0){ //Bind results to variables mysqli_stmt_bind_result($prepareQuote, $id, $word, $def); //If $id, $word, or $def is null abort and email error if(!is_null($id) && is_numeric($id) && !is_null($word) && !is_null($def)){ while($row=mysqli_stmt_fetch($prepareQuote)){ mysqli_autocommit($conn, FALSE); //Input into second table $updateQuery="UPDATE `quotes` SET `word`=?, `def`=? WHERE `category`=?"; //prepare insert query if($updateQuote=mysqli_prepare($conn, $updateQuery)){ //Bind the variables to the insert query mysqli_stmt_bind_param($updateQuote, "sss", $word, $def, $category); //execute insert statement mysqli_stmt_execute($updateQuote); //Store insert quote result set mysqli_stmt_store_result($updateQuote); //Check how many rows are returned on insert quote query if(mysqli_stmt_affected_rows($updateQuote) > 0){ //If query run sucessfully insert and update; if not rollback. //mark quote checked $checkedQuery="UPDATE `dictionary` SET `checked`=1 WHERE `id`=?"; //prepare checked query if($checkedQuote=mysqli_prepare($conn, $checkedQuery)){ mysqli_stmt_bind_param($checkedQuote, "i", $id); //execute checked statement mysqli_stmt_execute($checkedQuote); //Store checked quote result set mysqli_stmt_store_result($checkedQuote); //Check how many rows are returned on checked quote query if(mysqli_stmt_affected_rows($checkedQuote > 0)){ mysqli_commit($conn); } else{ echo 'Error #6 '; mysqli_rollback($conn); } } else{ echo 'Error #5'; //Email error die(); } } else{ echo 'Error #4'; mysqli_rollback($conn); } } else{ echo 'Error #3'; //Email error die(); } } } else{ echo 'Error #2'; //Query returned blank result set - Email Error } } else{ //If zero rows returned, uncheck rows in table for that specific category and re-run the query. $uncheckQuery="UPDATE `dictionary` SET `checked`=0 WHERE `category`=?"; if($uncheckQuotes=mysqli_prepare($conn, $uncheckQuery)){ //Bind the variable to the query mysqli_stmt_bind_param($uncheckQuotes, "s", $category); //execute statement mysqli_stmt_execute($uncheckQuotes); //Store result set mysqli_stmt_store_result($uncheckQuotes); //Check how many rows are returned if(mysqli_stmt_affected_rows($uncheckQuotes) > 0){ $_SESSION['loopCatch']++; header("Location: ./pullDailyQuotes.php"); } else{ //Email error } } } } } else{ //Email error echo 'Error #1'; die(); } ?> Edited by HDRebel88, 01 June 2014 - 08:54 PM. Not sure how to find what is causing my issue here, I'm running smarty which gives me this error if I switch PHP version to 7.4 (was on 7.3) : - Quote
ERRNO: 8 The line the error refers to is this : -
<p class="cart_del_info_box_text"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <span class="cart_del_info_box_message"><?php echo $_smarty_tpl->tpl_vars['cart']->value->mDelivery['cartdeliverymessage'];?>
How do I go about finding which file has the actual problem? Thanks for any pointers. My first post and I am not a programmer or familiar with the correct vocabulary associated with php. I thought I would give the following a go as it is the holidays and my php programmer is no where to be found. I am ok at following scripts to get a simple result, unfortunately the listing manager I am using is coded with Zend. The system is built on a curve2.com and I am pretty much stuck with what exists. I would like to add some more php outputs, which I don't think are too complicated, but I can't seem to get my head around pulling information from multiple tables in to 1 result. I am trying to pull all the data from a 'Listing' table in to 4 columns, which works ok. What I can not get around is trying to link up the 'Image' table to my 'Listing' table and pulling the main image in to my php output. There is a common 'id' but each 'id' has 4+ images and I would like to select the just main one and resize it smaller. So far, I have the following, which I have put together from following examples on this website. 'id' is the unique id for each record. <? $query="select * from listings"; $result=mysql_query($query); $cols=4; echo "<table>"; do{ echo "<tr>"; for($i=1;$i<=$cols;$i++){ $row=mysql_fetch_array($result); if($row){ $img = $row['image_path']; ?> <td> <table> <tr valign="top"> <td><img src="images/<?=$img ?>" /></td> <td> <b><a href="http://www.coralbayrealestate.com/search/show.php?id=<?=$row['id'] ?> "> <?=$row['title'] ?> </a> </b><br /> <?=$row['state'] ?><br /> $USD <?=number_format ($row['price']) ?><br /> </td> <td width="20"> </td> </tr> </table> </td> <? } else{ echo "<td> </td>"; } } } while($row); echo "</table>"; ?> The image table, called 'images' has 3 fields 'id' - individual photos id's 'listid' - Id record to the listing table 'fname' - image name Any guidance would be much appreciated on how to get the primary image on to the table. Happy holidays and best wishes to all for 2011. Sandydr I am getting the row results from mysql as called, but they appear as a straight line instead of new table row when I echo like: echo "TABLETABLETABLETABLE"; I am looking for: echo "TABLE TABLE TABLE TABLE"; Here is my code: Code: [Select] $brand = $_POST['brand']; $city = stripslashes($_POST['city']); $state = $_POST['state']; $zip_code = stripslashes($_POST['zip_code']); if($city !=""){ $query = "SELECT name, bus_type, street, city, state, zip_code, brand, quantity, price1, price2, date FROM `prices` WHERE city ='".$city."' AND state ='".$state."' AND brand = '".$brand."'"; }else{ $query = "SELECT name, bus_type, street, city, state, zip_code, brand, quantity, price1, price2, date FROM `prices` WHERE zip_code ='".$zip_code."'"; } $result = mysql_query($query); $count=mysql_num_rows($result); if($count==0 && $zip_code !=""){?> <td width="100%" class="style9">Sorry! There are no results for that city, state and brand.</td> <? }else{ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ ?> <td width="100%" class="style9"><?php echo "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td{$typ_image}</td> <td><b><a href=\"\" title=\"{$row['street']} {$row['city']}, {$row['state']}. {$row['zip_code']}\" target=\"_blank\">{$row['name']}</a></b><br>Last Updated:{$row['date']}</td> <td><b>{$row['brand']} - {$row['quantity']}</b><br>Before Tax:\${$row['price1']} After Tax:\${$row['price2']}</td> <td{$pago}</td> </tr> </table><BR>"; ?></td> <?php } } ?></table> <p> </p> </td> Hi, Mary Christmas My result of mysql database is LIMIT 8; now i have to retrieve and show this to two Horizontal columns As each columns 4 result. how to generate this Without tables!! only with DIV or UL/LI list . Thanks Hi There, I have an SQL query that returns 10 rows, which I want to echo over 2 columns and 5 rows, however, I want rows 1-5 on the left hand column and rows 6-10 on the right hand side. Is there an easy way to do this? Normally I would do a fetch_array but, that would place the rows in order of, left, right, left, right - if that makes sense? Table is a standard table with 2 columns and 5 rows. Thanks Matt Hello! I have this code Code: [Select] <?php include_once('../database_connection.php'); $thiskeyword = addslashes($_REQUEST['keyword']); $sqlquery = "Select * from nba_info where player_id like '%$thiskeyword' OR fname like '%$thiskeyword' OR lname like '%$thiskeyword' OR team like '%$thiskeyword' OR email like '%$thiskeyword'"; $result = MYSQL_QUERY($sqlquery); $numberOfRows = MYSQL_NUM_ROWS($result); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search Result</title> </head> <body><center><br /><br /> <?php if($numberOfRows==0) { die('You keywords haven\'t much any data from the database'); } else if($numberOfRows>0) { echo $numberOfRows. " Results have been found!"; $i = 0; ?> <table> <tr> <td>player_id</td> <td>fname</td> <td>lname</td> <td>team</td> <td>email</td> </tr> <?php while($i<$numberOfRows) { $player_id = MYSQL_RESULT($result,$i,"player_id"); $fname = MYSQL_RESULT($result,$i,"fname"); $lname = MYSQL_RESULT($result,$i,"lname"); $team = MYSQL_RESULT($result,$i,"team"); $email = MYSQL_RESULT($result,$i,"email"); ?> <tr> <td><? echo $player_id; ?></td> <td><? echo $fname; ?></td> <td><? echo $lname; ?></td> <td><? echo $team; ?></td> <td><? echo $email; ?></td> </tr> <?php $i++; } ?> </table> <?php } ?> <ul> <li><a href="/php/database/ManipulatingDatabase/add_database.php">Add New Player</a></li> <li><a href="/php/database/ManipulatingDatabase/edit_form.php">Edit Player</li> <li><a href="/php/database/ManipulatingDatabase/delete_form.php">Delete Player</li> <li><a href="/php/database/ManipulatingDatabase/search_form.php">Search Player</li> <li><a href="/php/database/ManipulatingDatabase/manipulate_database.php">BACK TO MAIN</a></li> </ul> </center> </body> </html> I have no problem with the sql statement as code Code: [Select] echo $numberOfRows. " Results have been found!"; is giving me a numbers of rows. The problem is the rows that have been found is not showing up in the html row. I wonder what the problem is.. anyone? I´ve reached to
<?php require_once('Connections/conexxion.php'); ?> <?php mysql_select_db($database_conexxion, $conexxion); $query_consulta = "SELECT venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos) as stock, cilindro, esfera FROM movimiento join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro on cilindro.id_cil=rx.id_cil join esfera on esfera.id_esf=rx.id_esf GROUP BY movimiento.id_item ORDER BY esfera desc, cilindro desc"; $consulta = mysql_query($query_consulta, $conexxion) or die(mysql_error()); $row_consulta = mysql_fetch_assoc($consulta); $totalRows_consulta = mysql_num_rows($consulta); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <?php echo "<table align=center>"; $columnes = 10; # Número de columnas (variable) if (($rows=mysql_num_rows($consulta))==0) { echo "<tr><td colspan=$columnes>No hay resultados en la BD.</td></tr> "; } else { echo "<tr><td colspan=$columnes>$rows Resultados </td></tr>"; } for ($i=1; $row = mysql_fetch_row ($consulta); $i++) { $resto = ($i % $columnes); # Número de celda del <tr> en que nos encontramos if ($resto == 1) {echo "<tr>";} # Si es la primera celda, abrimos <tr> echo "<td>$row[1]</td>"; if ($resto == 0) {echo "</tr>";} # Si es la última celda, cerramos </tr> } if ($resto <> 0) { # Si el resultado no es múltiple de $columnes acabamos de rellenar los huecos $ajust = $columnes - $resto; # Número de huecos necesarios for ($j = 0; $j < $ajust; $j++) {echo "<td> </td>";} echo "</tr>"; # Cerramos la última línea </tr> } mysql_close($connexion); echo "</table>"; ?> </body> </html> <?php mysql_free_result($consulta); ?>it "works", but results doesn´t start at number 1 but number 2 anyways, The intent of this table is to show the stock of a product, a lens, that has a range of Rx, we use to see this range this way, and show the stock this way would be very productive, but I can´t figure out how to achive it, any sugestion?? Edited by gralfitox, 16 December 2014 - 06:45 AM. I am having so much trouble with this. I want to create a html table that looks like this: Code: [Select] <table id="datatable"> <thead> <tr> <th></th> <th>test</th> <th>test 2</th> </tr> </thead> <tbody> <tr> <th>2011-03-17</th><td>1</td><td>0</td> </tr> <tr> <th>2011-03-18</th><td>3</td><td>2</td> </tr> <tr> <th>2011-03-19</th><td>1</td><td>0</td> </tr> </tbody> </table> out of this mysql result: opens | name | date 1 | test | 2011-03-17 3 | test | 2011-03-18 2 | test 2 | 2011-03-18 1 | test 2 | 2011-03-19 Here is my mysql code: Code: [Select] SELECT count( o.campaign_id ) AS opens, c.name, date(o.created_at) as date FROM opens o LEFT JOIN campaigns c ON c.id = o.campaign_id WHERE (o.created_at between '2011-03-17 00:00:00' and '2011-03-19 23:59:59') GROUP BY date,c.name I also attached a sql dump of my database. I am trying to update the database with isset to set the value of the variable to either null or the value entered by the user. Currently, if no value has been entered null is being set as a string causing the date field to populate with zeros. How do I code it so that it populates or sets the value as null and not as string null?
Here's my code: (yes I know sql injections it's still in development )
<?php I am retrieving a rowfrom a table and when I post the row variable it doesnt read it. ___ $query = "SELECT * FROM $tbl_name"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['name']; echo "<br />"; $postinfo = 'p_doctor_name=' . $row .'&p_name_type=A&p_search_type=BEGINS'; __ This outputs p_entity_name=&p_name_type=A&p_search_type=BEGINS Note that it is missing $row Do I need to put it in an array? Hi all, I have a number of tables within a mysql database and I'm stuck on how to pull information from one based on the results being displayed by another. The site shows items for sale where by all the product information is held in tablea, when an individual item is being displayed I need to be able to pull a manufacturer profile from tableb based on the manufacturer name stored in tablea column profile. The manufacturer name is already being called into the page by existing code as the site has always shown the manufacturer name, I just can't work out out to pull the new profile information in as well from the new table. Any help appreciated Iain Hello all brilliant minds, I'm a new in all this world of DB and coding and always i tried to avoid it because I think it is very hard (I'm trying to change now). problem: I have a text file (log.txt) have data like below ======================================== > rtrv-ls Command Accepted - Processing OXX 12-02-21 08:44:41 EST EAGLE5 42.0.1-63.38.31 rtrv-ls Command entered at terminal #7. ; OXX 12-02-21 08:44:41 EST EAGLE5 42.0.1-63.38.31 L3T SLT GWS GWS GWS LSN APCI (SS7) SCRN SET SET BEI LST LNKS ACT MES DIS SLSCI NIS gtcen1pls 7-010-4 none 1 2 no D 2 off off off no off gtgdv1pls 7-010-5 none 1 2 no D 2 off off off no off > rtrv-sid Command Accepted - Processing OXX 12-02-21 08:43:43 EST EAGLE5 42.0.1-63.38.31 rtrv-sid Command entered at terminal #7. ; OXX 12-02-21 08:43:43 EST EAGLE5 42.0.1-63.38.31 PCA PCI PCN CLLI PCTYPE 010-010-010 7-055-1 01830 crher1p OTHER ; . . may output like this starting always with > =================================================== Then I have SQL DB that have column with "rtrv-ls" and "rtrv-sid" Requirement : A) Use Php to open the .txt file, I used HTML form so the user can upload the file on the browser then B) Search for the column name as pattern C)Send query to MYSQL to update DB with Data for each column D) Query the Mysql for several possible outputs (I've done this part using HTML form and simple php code as below. <?php // If we got a GET request on the page from HTML part of the code, we will want to store the data in a variable e.g $my_country // So country will be passed via GET and will be stored in $my_country variable. $host="localhost"; $con_usr="aomar"; $con_pass="nokia"; if ($_POST) { $user_input = $_POST['my_log'] ; // We use the request to search in Database and return the result, First step we need to connect to the database // $connect = mysql_connect ($host,$con_usr,$con_pass); // Then we need to select database to run the query and return the result the connection stored in the $connect ressource // if ($connect) { mysql_select_db("eagle",$connect); // We store the query in variable $query becuase is it quite long text; we actually attach our varaiable $my_log passed from HTML // $query = "SELECT `".$user_input."` FROM `ss7`"; //$update="INSERT INTO ss7 ('".$user_input."') VLAUES ('; // SO if user selected Egypt it will be stored in (name=my_country) variable from HTML and will be send via GET // Then we store the query results in a variable called $result $result = mysql_query ($query) ; $arr= mysql_fetch_array($result); echo nl2br ($arr["$user_input"]); //Finally we return what we want from the array. // Print the output as we wish. in case of row data like STP output, use the nl2br to preserve the output as it was written to MYSQL DB // We need to check if the Query return no value (!$arr) , and print corresponding action } //================SECONED PART WHEN I LOAD THE LOG FILE TO BE STORED IN MYSQL================// //close the db mysql_close ($connect); } ?> <html> <body> <form action = "eagle.php?pmode=my_file" method = "POST" enctype="multipart/form-data> <fieldset> <legend> Enter you log file here and click Save: </br> </legend> <label for="my_file"> This Is My Capture File </label> <input type = "file" name ="my_file" style=margin:auto > </input><br/><br/> <input type="submit" value="Upload file"> </fieldset> </form> </body> </html> <html> <body> <title>Eagle Data Base Store</title> <form action = "eagle.php?pmode=my_log" method = "POST"> <fieldset> <legend> Please Select the DB you would like to retrive </legend> <br/><br/> <input type = "radio" name ="my_log" value = "rtrv-serial-num">Serial-Num</input> <input type = "radio" name ="my_log" value = "rtrv-stp">rtrv-stp</input> <input type = "radio" name ="my_log" value = "rtrv-feat">rtrv-feat</input> <input type = "radio" name ="my_log" value = "rtrv-dstn">rtrv-dstn</input> <input type = "radio" name ="my_log" value = "rtrv-rte">rtrv-rte</input> <input type = "radio" name ="my_log" value = "rtrv-trm">rtrv-trm</input> <input type = "radio" name ="my_log" value = "rtrv-slk">rtrv-slk</input><br/> <br/> <input type = "radio" name ="my_log" value = "rtrv-ls">rtrv-ls</input> <input type = "radio" name ="my_log" value = "rtrv-sccpopts">rtrv-sccpopts</input> <input type = "radio" name ="my_log" value = "rtrv-stpopts">rtrv-stpopts</input> <input type = "radio" name ="my_log" value = "rtrv-gsmopts">rtrv-gsmopts</input> <input type = "radio" name ="my_log" value = "rtrv-cmd">rtrv-cmd</input> <input type = "radio" name ="my_log" value = "rtrv-assoc">rtrv-assoc</input><br/> <br/> <input type = "radio" name ="my_log" value = "rtrv-gpl">rtrv-gpl</input> <input type = "radio" name ="my_log" value = "rtrv-ip-host">rtrv-ip-host</input> <input type = "radio" name ="my_log" value = "rtrv-ip-lnk">rtrv-ip-lnk</input> <input type = "radio" name ="my_log" value = "rtrv-secu-trm">rtrv-secu-trm</input> <input type = "radio" name ="my_log" value = "rtrv-secu-user">rtrc-secu-user</input> <input type = "radio" name ="my_log" value = "rept-stat-sys">rept-stat-sys</input><br/><br/> <input type = "radio" name ="my_log" value = "rept-stat-clk">rept-stat-clk</input> <input type = "radio" name ="my_log" value = "rtrv-ctrl-feat">rtrv-ctrl-feat</input> <input type = "radio" name ="my_log" value = "rtrv-tabl-capacity">rtrv-tabl-capacity</input><br/><br/> <input type = "submit" value = "Show Selected Table"/> </fieldset> </form> </body> </html> ==========================================END OF CODE=========================== *** Sorry for the many comments but I want to be sure I remember why I do that . You help is much appreciated (Please note that need to understand more than I need the Code itself) OK, Here is the code $sql = "SELECT TrialListing.listingID AS Trial, TrialClass.classID AS Class, place.place_name AS Place, CONCAT_WS( ' ', pedigree.pretitle, pedigree.`Name`) AS Hound, CONCAT_WS( ' ', ped2.pretitle, ped2. NAME )AS Sire, CONCAT_WS( ' ', ped3.pretitle, ped3. NAME )AS Dam, pedigree.Breeder, pedigree.`Owner`, CASE WHEN placement.place_id < 5 THEN TRUNCATE(TrialClass.number_of_entrants / placement.place_id,2) WHEN placement.place_id = 5 THEN '' ELSE 0 END AS Score FROM TrialListing Left Join TrialClass ON TrialListing.listingID = TrialClass.listingID JOIN placement ON placement.event_id = TrialClass.trialClassID JOIN pedigree ON pedigree.PedigreeId = placement.hound_id LEFT OUTER JOIN pedigree AS ped2 ON pedigree.SireId = ped2.PedigreeId LEFT OUTER JOIN pedigree AS ped3 ON pedigree.DamId = ped3.PedigreeId LEFT JOIN place ON place.place_id = placement.place_id WHERE TrialListing.listingID = 11 ORDER BY Class, FIELD(place.place_id, '1', '2', '3', '4', '0') "; // Database Query $result = mysql_query("$sql"); // Database Query result $num_rows = mysql_num_rows($result); // Starts the table echo "<table class=\"clubList\">\n <tr> <th>trialID</th> <th>ClassID</th> <th>Place</th> <th>Hound</th> <th>Sire</th> <th>Dam</th> <th>Score</th> </tr>"; // Create the contents of the table. for( $i = 0; $i < $row = mysql_fetch_array($result); $i++){ echo "<tr>\n" ."<td>".$row["Trial"]."</td>\n" ."<td>".$row["Class"]."</td>\n" ."<td>".$row["Place"]."</td>\n" ."<td>".$row["Hound"]."</td>\n" ."<td>".$row["Sire"]."</td>\n" ."<td>".$row["Dam"]."</td>\n" ."<td>".$row["Score"]."</td>\n" ."</tr>";} echo "</TABLE>"; Here is the output, I added the TrialID & ClassID for informational purposes, they do not need to be displayed in the live table. trialID ClassID Place Hound Sire Dam Score 11 1 1st Eaton Brook Tug Hill Tatonka Eaton Brook Hickety Hawk Eaton Brook Gunner's Beulah 43.00 11 1 2nd FC North Bend Igloo FC DFJ Murphy White IFC Brad-Ju's Bella Donna 21.50 11 1 3rd FC North Bend Igloo FC DFJ Murphy White IFC Brad-Ju's Bella Donna 14.33 11 1 4th Rail Road Spike VI Elwell's Mike Elwell's Hannah 10.75 11 1 NBQ FC Fish Creek Spike Fish Creek Bull II Fish Creek Susie [H849395] 11 2 1st Enman Hill Sweet Poppy FTCH Straight Arrow Lucky of Coos 32.00 11 2 2nd Fishflakes Penny At Harehaven FTCH Jill's Fair-Isle Spud FTCH Millbridge Brownie 16.00 11 2 3rd Line Elm Flakers IFC Flakers Rex IFC Line Elm Ginger 10.66 11 2 4th FTCH Fareast Mookie FTCH Mellowrun Sly FTCH Cape Breton Maude 8.00 11 2 NBQ FTCH Mellowrun Sly Mellowrun Skylighter FTCH Mellowrun Becka 11 3 1st Bojangle V Lee Otworth Half Acre's Cocoa Candy 23.00 11 3 2nd Gay Doll Gay Roll II Gay Idol 11.50 11 3 3rd Bruce's Blue Lady FC Kilsock's Blue Creek Bart Bishopville's Zippy 7.66 11 3 4th FC Pearson Creek Barbin FC Pearson Creek Barbarian FC B-Line Stubby 5.75 11 3 NBQ Sims Creek Cricket Ronnie Joe Sims Creek Tiny 11 4 1st FTCH Fareast Mookie FTCH Mellowrun Sly FTCH Cape Breton Maude 26.00 11 4 2nd FTCH Mellowrun Sly Mellowrun Skylighter FTCH Mellowrun Becka 13.00 11 4 3rd Fishflakes Penny At Harehaven FTCH Jill's Fair-Isle Spud FTCH Millbridge Brownie 8.66 11 4 4th Enman Hill Sweet Poppy FTCH Straight Arrow Lucky of Coos 6.50 11 4 NBQ Line Elm Flakers IFC Flakers Rex IFC Line Elm Ginger Below is what I would like to generate. How do I word or nest the proper PHP code/loops to accomplish this? ClassID Place Hound Sire Dam Score 1st Eaton Brook Tug Hill Tatonka Eaton Brook Hickety Hawk Eaton Brook Gunner's Beulah 43.00 2nd FC North Bend Igloo FC DFJ Murphy White IFC Brad-Ju's Bella Donna 21.50 3rd FC North Bend Igloo FC DFJ Murphy White IFC Brad-Ju's Bella Donna 14.33 4th Rail Road Spike VI Elwell's Mike Elwell's Hannah 10.75 NBQ FC Fish Creek Spike Fish Creek Bull II Fish Creek Susie [H849395] ClassID Place Hound Sire Dam Score 1st Enman Hill Sweet Poppy FTCH Straight Arrow Lucky of Coos 32.00 2nd Fishflakes Penny At Harehaven FTCH Jill's Fair-Isle Spud FTCH Millbridge Brownie 16.00 3rd Line Elm Flakers IFC Flakers Rex IFC Line Elm Ginger 10.66 4th FTCH Fareast Mookie FTCH Mellowrun Sly FTCH Cape Breton Maude 8.00 NBQ FTCH Mellowrun Sly Mellowrun Skylighter FTCH Mellowrun Becka ClassID Place Hound Sire Dam Score 1st Bojangle V Lee Otworth Half Acre's Cocoa Candy 23.00 2nd Gay Doll Gay Roll II Gay Idol 11.50 3rd Bruce's Blue Lady FC Kilsock's Blue Creek Bart Bishopville's Zippy 7.66 4th FC Pearson Creek Barbin FC Pearson Creek Barbarian FC B-Line Stubby 5.75 NBQ Sims Creek Cricket Ronnie Joe Sims Creek Tiny ClassID Place Hound Sire Dam Score 1st FTCH Fareast Mookie FTCH Mellowrun Sly FTCH Cape Breton Maude 26.00 2nd FTCH Mellowrun Sly Mellowrun Skylighter FTCH Mellowrun Becka 13.00 3rd Fishflakes Penny At Harehaven FTCH Jill's Fair-Isle Spud FTCH Millbridge Brownie 8.66 4th Enman Hill Sweet Poppy FTCH Straight Arrow Lucky of Coos 6.50 NBQ Line Elm Flakers IFC Flakers Rex IFC Line Elm Ginger I am really lost here with this date issue of mine. The below code is the last part of a query: Code: [Select] $defendercheck_3 = $row_checkifattacked3['atdate']; $defendercheck1_3 = strtotime("$defendercheck_3"); $defendercheck2_3 = date("D", $defendercheck1_3); The query does not return any results as expected, but when echoing the various steps I get following: echo "$defendercheck3"; = nothing (as expected) echo "$defendercheck1_3"; = nothing (as expected) echo "$defendercheck2_3"; = result! (NOT expected) why does it return anything on "date("D", $defendercheck1_3)" when "$defendercheck1_3" is blank? while($row = mysql_fetch_row($query)) { echo "<tr>"; echo '<td>' . $row[0] . '</td>'; echo '<td>' . $row[1] . '</td>'; echo '<td>' . $row[2] . '</td>'; echo '<td>' . $row[3] . '</td>'; echo '<td>' . $row[4] . '</td>'; echo "</tr>\n"; } Currently I have this code. I would like to make it print certain text, let's say... 'car', if the value of table's column 'automobiles' is equal to 0. Otherwise - print the real value. I've tried if statement and $one = $two... But that apparently didn't worked. Thanks. Okay I don't mind telling you I am very perplexed on how to read a text file delimited with TAB into a HTML Table using PHP. I don't know where to begin, I have read about 12 examples and get more confused each time. I hope someone can help me. I am looking to read this delimited (TAB) file skipping the first line and reading array's 2,5,6,7,8,9, and 10, then displaying in a HTML Table. Corresponding Headers would be nice. The php file does not work at the present because I am trying to read the array sections by row.
Thank You in advance
Attached Files
ParseText.php 852bytes
3 downloads
JimTest.txt 16.88KB
1 downloads |