PHP - Not Showing Anything
I decided to redo the individual roster page I have on my site and came up with this.
<?php if(isset($_GET['username']) && $_GET['username'] != '') { $username = $_GET['username']; $query = "SELECT bio.username AS username, bio.charactername AS charactername, bio.id AS id, bio.style_id AS style FROM `efed_bio` AS bio ON bio.id = ebw.bio_id WHERE bio.username = '$username'"; if(!$result = mysql_query($query)) while ($row = mysql_fetch_assoc($result)) { $fieldarray=array('id','username','charactername','style'); foreach ($fieldarray as $fieldlabel) { if (isset($row[$fieldlabel])) { $$fieldlabel=$row[$fieldlabel]; $$fieldlabel=cleanquerydata($$fieldlabel); } } } } ?> <h1><?php echo $charactername; ?>'s Biography</h1> <?php echo getBioMenu($style,$username); ?> <? //If the GET page variable is biography, display the biography page if ($page == 'biography') { echo getBiopgrahy($style,$id); } //Or if the GET page variable is gallery, display the gallery page elseif ($page == 'gallery') { echo getGallery($style,$id); } //If the GET page variable is news, display the news page elseif ($page == 'news') { echo getNews($$id); } //If the GET page variable is segments, display the segments page elseif ($page == 'segments') { echo getBioSegments($id,S); } //If the GET page variable is matches, display the matches page elseif ($page == 'matches') { echo getBioSegments($id,M); } elseif ($page == 'chronology') { echo getChronology($id); } //Otherwise display the bio else { echo getBio($style,$id); } ?> The list of characters are listed he http://kansasoutlawwrestling.com/roster An example of someone's individual roster page is located he http://kansasoutlawwrestling.com/bio?username=oriel Similar TutorialsI am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - Code: [Select] <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> hi all I have a table which i have got results from a database. My question If i want to display the details of a particular row. How do I do that? Thanks Rgds I am wanting to echo one of these 4 statements depending on the 'status' value. Currently it is showing the status value on the 2nd line but not the statement below.. Code: [Select] <li> <strong>Status: </strong><?php more_fields('status') ?> <?php if (more_fields('status')=="Red") echo "Your account is currently undergoing judgement"; elseif (more_fields('status')=="Green") echo "Your account is currently Live"; elseif (more_fields('status')=="Yellow") echo "Your account is currently undergoing site visits"; elseif (more_fields('status')=="Blue") echo "Your account is currently undergoing insolvency/liquidation";?> </li> any help appreciated. Thanks, Jake I have a really strange query for you all to figure out why I'm not coming up with the right SELECT statement. I've echoed it and I'll show you what I get for a result from the echo as well. Table- Users Fields- id,creator_id,username,password,firstname,lastname,email,status_id,isadmin,datecreated $query = "SELECT CONCAT_WS(' ', firstname, lastname) AS name, CONCAT_WS(' ', firstname, lastname) AS handler, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, id, username, email FROM handlers WHERE handlers.id = handlers.creator_id"; produced this result... SELECT CONCAT_WS(' ', firstname, lastname) AS name, CONCAT_WS(' ', firstname, lastname) AS handler, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, id, username, email FROM handlers WHERE handlers.id = handlers.creator_id php data table code: <?php $query = "SELECT CONCAT_WS(' ', firstname, lastname) AS name, CONCAT_WS(' ', firstname, lastname) AS handler, DATE_FORMAT(datecreated, '%M %d, %Y') AS datecreated, id, username, email FROM handlers WHERE handlers.id = handlers.creator_id"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); echo $query; <?php if ($rows > 0) { ?> <table cellspacing="0" class="listTable" id="handlersPageList"> <!-- Thead --> <thead> <tr> <th class="first"><div></div></th> <th><a href="#" title="Handler Name">Handler Name</a></th> <th><a href="#" title="Handler Username">Handler Username</a></th> <th><a href="#" title="Handler Emal">Handler Email</a></th> <th><a href="#" title="Creator">Creator</a></th> <th class="last"><a href="#" title="Date Created">Date Created</a></th> </tr> </thead> while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td><input type=checkbox class=checkbox value="' . $row['id'] . '" /></td> <td>' . $row['handler'] . '</td> <td>' . $row['username'] . '</td> <td><a href="mailto:' . $row['email'] . '>' . $row['email'] . '</a></td> <td>' . $row['name'] . '</td> <td class=last>' . $row['datecreated'] . '</td> </tr>'; } ?> I just decided to take out the parts of the page that would be needed to answer this problem instead of the whole file. This is a little confusing okay lets say the first user is the Administrator with an id of 1 obviously has a first name and last name and username and email and the date he registered is his datecreated and his creator_id is going to be preset because he created it himself so its going to be 1. The 1st row in the database displays fine however I have 4 other rows that for some reason aren't displaying. And don't know why. For handlers 2-4 they all have their own first and last names and usernames and everything else however when it comes to the creator_id those 3 have a creator_id of 1 representing that the Administrator created it so in the data table instead of it showing the value of 1 for the creator_id I just want it to get the CONCCAT version of the first and last name of the Administrator. In the past I have not done a very good job of explaining things so I hope this is more than clarified my intention with my code and what it should do and what it is doing wrong right now. If you have any other questions please ask. hello team, can you please look at this code snippet and tell me why it is showing the following data this way? <?php # jeff Exp $ include("app.php"); $page->set("title", "Business & Commerical"); $what = $page->getvar("what"); $type = $page->getvar("type"); $dt = new xDataTable('width="500"'); $form = new Form(); if($what == "submit") $html->set("readonly", true); $dt->header($_types{$type} . " Quote"); $form->get_contact_form(true); When I run it, it shows like this: set("title", "Business & Commerical"); $what = $page->getvar("what"); $type = $page->getvar("type"); $dt = new xDataTable('width="500"'); $form = new Form(); if($what == "submit") $html->set("readonly", true); $dt->header($_types{$type} . " Quote"); $form->get_contact_form(true); switch ($type) { case "comp": $dt->left("Business Type:"); $dt->cell($html->select("business_type", $_business_type, 1, "", $page->getvar("business_type"), "(select)")); $dt->left("Federal Tax ID:"); $dt->cell($html->textfield("tax_id", $page->getvar("tax_id"), 12)); $dt->left("If Individual, Owner SSN#:"); $dt->cell($html->textfield("ssn", $page->getvar("ssn"), 12)); $dt->cell("Spouse SSN#:"); $dt->cell($html->textfield("spouse_ssn", $page->getvar("spouse_ssn"), 12)); just a small sample. What am I doing wrong? Thanks alot in advance Hi People. Here is a form that is supposed to read from my database. My primary key is called "index" and I have about 300 records in the database. I wanted to be able to view the records but when I load this page the "php" part is empty. I simply get given a blank form. I know it is connecting to the DB OK because I changed one letter in the password and then got a "can't connect to the database error" just to test it out. Code: [Select] <?php $host = 'localhost'; $usr = "the_db_user"; $password = 'not_shared_on_forum'; $db_name = 'stranded'; function cr($string){ $clean_string = str_replace("rn","<BR>",$string); return $clean_string; } //$id = 11; if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from HelperFormData where index = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!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>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> Surname: <? echo $rs["surname"]; ?> <table width="500" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="2"> <tr> <td colspan="5">Record number: <? echo $rs["index"]; ?></td> </tr> <tr> <td width="120" bgcolor = #E6F8EB>Surname</td> <td width="120" bgcolor = #E6F8EB>First Name</td> <td width="120" bgcolor = #E6F8EB>phone1</td> <td width="120" bgcolor = #E6F8EB>phone2</td> <td width="120" bgcolor = #E6F8EB>Location</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo $rs["surname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["firstname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone1"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone2"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["location"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Qualifications</td> <td bgcolor = #dbeff8>Expertise</td> <td bgcolor = #dbeff8>Assistance</td> <td bgcolor = #dbeff8>Languages</td> <td bgcolor = #dbeff8>E-Mail</td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["qualifications"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["expertise"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["assistance"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["languages"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["e_mail"]; ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Consent</td> <td bgcolor = #E6F8EB>Published</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo $rs["consent"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_callsign"]; ?></strong></td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td colspan="5"><p>Comments:<br /> <strong><? echo $rs["comments"]; ?></strong></td> </tr> </table> </body> </html> </html> Hi all, I have a simple upload form which is just to upload an image to a folder, this all works fine apart from one bit, once the image has been submitted then a box appears thanking the user for their upload and a close box link, then the original form also appears! I dont want this to appear once I file has been uploaded. I thought my below code would achieve that with an if statement but it is not working: <?php session_start(); $user_id = $_SESSION['user_id']; if (file_exists($user_id.'.'.$extension)) { define ("MAX_SIZE","100"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $image_name=$user_id.'.'.$extension; $newname="romimages/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} if(isset($_POST['Submit']) && !$errors) { ?> <link href="../Styles/form_dark.css" rel="stylesheet" type="text/css" /> <form class="dark" action="" method="post" > <ol> <li> <fieldset> <legend>Rom Logo Uploaded!</legend> <p> </p> <ol> <li> <label for="">Your image has been uploaded, you can now close this window</label> </li> </ol> </fieldset> </li> </ol> <br> <input type="submit" value="Close" name="submit" onClick="return parent.parent.GB_hide()" > </p> </form> <?php } } else { ?> <link href="../Styles/form_dark.css" rel="stylesheet" type="text/css" /> <form method="post" enctype="multipart/form-data" action="" class="dark"> <ol> <li> <input type="file" name="image" width="45px"> </li><br> <br> <li> <input name="Submit" type="submit" value="Upload image"> </form> <?php } ?> thanks Hello all, I am trying to get a simple members.php page to show some HTML but I cannot figure out why it will not display.. Code: [Select] <?php mysql_connect("myserver", "myname", "mypass") or die(mysql_error()); mysql_select_db("mydb") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM Users WHERE name = '$name'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($password != $info['password']) { header("Location: login.php"); } else { ?> <html> <body> <h1>WHY</h1> </body> </html> <?php } } } else { header("Location: login.php"); } ?> I was googling and read somewhere that it might be a session bug after the initial '<?php tag'? Any help would be greatly appreciated Tokae Hi, I am using the include function to link my header and menu up to my files. My folder structure is: WWW Folder -head.html -menu.html -homepage.php Images Folder Blog Folder -index.php The head.html and menu.html have links to images kept within the images folder. homepage.php and index.php both have include functions to include the menu and header thus including the images. homepage.php works fine the images show up however blog.php links to the head and menu but does not show up the images. my include function for index.php is: <?php include ("..\menu.html"); ?> I have attached a print screen of what the index.php looks like, its obvious that its picking up the head and menu as its showing the image names but not showing the images. Can anybody help it's really confusing me? Thanks Hi, I just connect to my server through ftp. i want to edit php.ini file. which is placed in /etc/php.ini "etc" folder. but i'm unable to see etc folder. there are only two folders one is cgi-bin and other is www. can anyone help me to find out etc folder. i've check to show hidden files in filezilla. Thanks Hi Friends, I have form in that i am sending some values using POST method. But i cant able to get values using $_POST['var'] or $_REQEUST['var'] Data is not coming in IE6, But it is coming in firefox and other browsers even in IE8. What may be problem? any settings i have to make for IE6. ? Any suggestions i have the following code: <?php session_start(); include "connect.php"; $queryFinished = mysql_query("SELECT * FROM `finished` ORDER BY auctionID DESC LIMIT 10;") or die(mysql_error()); $queryAdmin = mysql_query("SELECT maxClosed FROM `admin`;") or die(mysql_error()); //echo $queryAuctionID." = Auction ID<br />"; $username = mysql_fetch_assoc($queryFinished); $queryShip = mysql_query("SELECT * FROM ships WHERE typeName='$username[itemName]';") or die(mysql_error()); $getShip = mysql_fetch_assoc($queryShip); $shipID = $getShip[typeID]; echo "<img src='http://image.eveonline.com/Character/".$username[charid]."_32.jpg'> <span class='eveyellow'>".$username[username]."</span> has won a <img src='/images/types/shiptypes_png/32_32/".$shipID.".png'/> ".$username[itemName]." with ticket number #".$username[ticketNumber]."<br />"; ?> it basically lists the most recent auctions that have won, but even though i set the query to LIMIT by 10 it still only shows the 1? is something above sticking out to anyone? i know it looks messy but im still learning. I am developing hospital managment system using php. I have IPD data sheet. When I select patient it is not showing pt data as it should do. Please let me know if any coding needs to place here. I am new to PHP. Below is my code <?php //create array to temporarily grab variables $input_arr = array(); //grabs the $_POST variables and adds slashes foreach ($_POST as $key => $input_arr) { $_POST[$key] = addslashes($input_arr); } ?> <?php session_start(); $db = mysqli_connect('localhost', 'root', '', 'ratanba_new'); // initialize variables $reg_no = ""; $name = ""; $father_name = ""; $sir_name = ""; $sex = ""; $age = ""; $full_name = ""; $dob = ""; $update = false; $patient_master_id = ""; $ipd_id = 0; $IPNo = ""; $fees = ""; $opd_date = ""; $pulse = ""; $bps = ""; $bpd = ""; $weight = ""; $spo2 = ""; if (isset($_POST['admit'])) { function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = ucwords($data); return $data; } $patient_master_id = $_POST['patient_master_id']; $IPNo = $_POST['IPNo']; $RegNo = $_POST['reg_no']; $Name = $_POST['Name']; $Age = $_POST['Age']; $Sex = $_POST['sex']; $Contact1 = $_POST['Contact1']; $Relation1 = $_POST['Relation1']; $Mobile1 = $_POST['Mobile1']; $Contact2 = $_POST['Contact2']; $Relation2 = $_POST['Relation2']; $Mobile2 = $_POST['Mobile2']; $Adate = $_POST['Adate']; $Award = $_POST['Award']; mysqli_query($db, "INSERT INTO IPD (IPNo, RegNo, Name, Age, Sex, Contact1, Relation1, Mobile1, Contact2, Relation2, Mobile2, Adate, Award) VALUES ('$IPNo', '$RegNo', '$Name', '$Age', '$Sex', '$Contact1', '$Relation1', '$Mobile1', '$Contact2', '$Relation2', '$Mobile2', NOW(), '$Award')"); $_SESSION['message'] = "New Admission Successfull !"; header('location: ../ipd.php'); } if (isset($_POST['Discharge'])) { $ipd_id = $_POST['ipd_id']; $Outcome = $_POST['Outcome']; mysqli_query($db, "UPDATE ipd SET Outcome='$Outcome', Ddate=NOW() WHERE ipd_id=$ipd_id"); $_SESSION['message'] = "Patient discharged Successfull !"; header('location: ../ipd.php'); } if (isset($_POST['final_discharge'])) { $ipd_id = $_POST['ipd_id']; $History = $_POST['History']; $Examination = $_POST['Examination']; $Investigation = $_POST['Investigation']; $Advise = $_POST['Advise']; $Diagnosis = $_POST['Diagnosis']; $Treatment = $_POST['Treatment']; $Operation = $_POST['Operation']; $OTnote = $_POST['OTnote']; $Condition1 = $_POST['Condition1']; $Note = $_POST['Note']; mysqli_query($db, "UPDATE ipd SET History='$History', Examination='$Examination', Investigation='$Investigation', Diagnosis='$Diagnosis', Operation='$Operation', OTnote='$OTnote', Condition1='$Condition1', Advise ='$Advise', Treatment='$Treatment', Note='$Note' WHERE ipd_id=$ipd_id"); $_SESSION['message'] = "Discharge saved Successfull !"; header('location: ../doctor/discharge.php'); } $results = mysqli_query($db, "SELECT * FROM IPD "); ?> Edited May 8 by Barand Coding was missed I am working on a code that I started along time ago but having problem showing the end time, could somebody please have a look at my code to see what I am missing. Thanks Code: [Select] $getEvent_sql = "SELECT id, event_title, event_shortdesc, date_format(event_start, '%l:%i %p') as fmt_date, date_format(event_end, '%l:%i %p') as fmt_enddate FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start)= '".$y."' ORDER BY event_start"; $getEvent_res = mysql_query($getEvent_sql, $mysql) or die(mysql_error($mysql)); if (mysql_num_rows($getEvent_res) > 0){ $event_txt = "<ul>"; while($ev = @mysql_fetch_array($getEvent_res)){ $evid = $ev["id"]; $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $fmt_date = $ev["fmt_date"]; $fmt_enddate = $ev["fmt_enddate"]; $event_txt .= "<li><a href=editevent.php?id=$evid>$editevent</a><a href=deleteevent.php?id=$evid>$deleteevent</a><strong>".$fmt_date."</strong>: ".$event_title."<br/>".$event_shortdesc."</li>"; } $event_txt .="</ul>"; mysql_free_result($getEvent_res); } else { $event_txt = ""; } mysql_close($mysql); if ($event_txt != ""){ echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } Hi: Can someone tell me why the code below is not displaying any data. It's suppose to write the calendar dates and event info, but nothing is showing up. No errors, either .. ?? Code: [Select] <td width="50" <?=hiLightEvt($month,$i,$year);?>> <?php if(isset($_GET['full'])){ $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['calName']; }else{ $sql="select calID, calDate, calName, calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ echo $row['calName']; ?> <a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$row['calDate'];?></a> <?php } } ?> </td> Help, please .... I am working on building a code that will check the results returned from and xml pull to see if they match the database and print back pass or fail on the screen, it works for the first result but then fails to display anything else. any help on where I went wrong would be helpful. Code: [Select] <?php function pass($name, $level) { $sql1 = "SELECT * FROM `reqskills` WHERE `level` > 0 and `name` = '$name'"; $result1 = mysql_query($sql1); while($row1 = mysql_fetch_array($result1)) { if($level >= $row1['level']) { echo "Pass"; } Else { echo "Fail"; } } } $API = "address removed"; $xml = simplexml_load_file($API); $sql = "SELECT * FROM `reqskills` WHERE `level` > 0"; $result = mysql_query($sql); echo "<table width=100%"; echo "<tr><td>Skill</td><td>Level</td><td>Pass</td></tr>"; while($row = mysql_fetch_array($result)) { ?> <tr> <td><?php echo $row['name'] ?></td> <td><?php echo $row['level'] ?></td> <td><?php foreach ($xml->result->rowset[0] as $value) { $typeID = $value['typeID']; $sql = "select * from `invTypes` WHERE `typeID` = $typeID"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { echo pass($row['typeName'],$value['level']); }} echo "</td></tr>"; } echo"</table>"; ?> Hi guys
I am using the code below to show distinct months using one query then for each month I am trying to show a list of fixtures for the month, the problem I have is only one month is showing.
where am i going wrong?
<?php //find distinct months $sql="SELECT DISTINCT MONTH( match_date ) AS MONTH FROM tbl_fixtures WHERE season_id =$current_season UNION SELECT DISTINCT MONTH( match_date ) AS MONTH FROM tbl_gp WHERE season_id =$current_season"; $result=mysqli_query($dbConn, $sql); if(mysqli_num_rows($result)>0){ while($row=mysqli_fetch_assoc($result)){ $month=$row['MONTH']; echo '<div class="fixtureMonth"> <h2>'.$months[$month].'</h2> </div> <div class="fixtures">'; //find fixtures for month $sql="SELECT Opposition, match_date, competition, tbl_clubs.club_name AS club, image, HomeAway, team, opposition_points, points FROM tbl_fixtures INNER JOIN tbl_clubs ON tbl_fixtures.club = tbl_clubs.club_id WHERE season_id =$current_season and MONTH(match_date)=$month UNION SELECT Opposition, match_date, \"SGP\" AS competition, \"SGP\" AS club, \"sgp.png\" AS image, \"\" as HomeAway, \"\" as team, \"\" as opposition_points, points FROM tbl_gp WHERE season_id =$current_season and MONTH(match_date)=$month ORDER BY match_date"; $result=mysqli_query($dbConn,$sql)or die(mysqli_error($dbConn)); if(mysqli_num_rows($result)==0){ echo no_fixtures_found; } else{ echo '<table class="fixturesTable">'; while($row=mysqli_fetch_assoc($result)){ echo'<tr> <td>'.date("d-M-Y",strtotime($row['match_date'])).'</td> <td><img src="'.$shopConfig['url'].'images/'.$row['image'].'"/></td> <td>'.$row['Opposition'].'</td> <td>'.$row['HomeAway'].'</td> <td><b>'.$row['team'].'</b>-'.$row['opposition_points'].'</td> <td>'.$row['team'].'</td> </tr>'; } echo '</table>'; } echo '</div>'; } } ?> Hello: I have this bit of code in the works (which does not work): Code: [Select] <?php if ( $mySubHeader; != "" ) { echo " <h2> <?php echo $mySubHeader; ?> </h2> "; } What I am trying to do is to show the H2 tag only if it has a value from the database. Otherwise, I do not want to show it. What is the correct way to do this? Thanks. |