PHP - Get_headers() Not Performing Like I Expected
I wish to find a way to test if multiple sites are up or not.
I have been using get_headers but it seems that this does not do what I thought I would. I wish to know if the sites are down or not. Is there another function that can test what state the site is in. i.e. server not found, server issues prevented the page from showing... Using get_headers will still show the site is live even if the server is not found, due to server problems, if any. Similar TutorialsHi everyone!
I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. In this case I have to rewrite the xml with this script. Situation is not optimal, I'm running the chunk script because we're stuck with the execution time limit too. Export filter: This loops over a xml file and splits it into chunks <?php //ini_set('max_execution_time', 10); // ---- includes if ( ! defined('ABSPATH') ) { require_once( dirname( __FILE__ ) . '/wp-load.php' ); } // ---- end includes // console function vwaconsole($input) { $disabled = false; if ($disabled === false) { $a = print_r($input.'</br>'); $a = $input; echo "<script>console.log( '--log--: " . $a . "' );</script>"; } } //end console // settings // $chunk_size = 20; // $home = constant( 'ABSPATH' ); $xml_path = $home."/wp-content/uploads/wpallimport/files/Bastiaansen.xml"; if (fopen($xml_path,"r") != true) { vwaconsole("xml file does not exist"); exit(); } $xml = new DOMDocument(); $xml->formatOutput = true; $xml->preserveWhiteSpace = false; $xml->load($xml_path); // Main program // creates another file to be filled by sub scripts if (!empty($xml)) { vwaconsole("Running main program"); // backup xml first $date = "_".date("Y M D h i"); $date = str_replace(' ', '_', $date); $xpath = new DOMXpath($xml); $items = $xpath->query("//aanbiedingen//item"); $loopcount = 0; $processedamount = 0; $islast = 0; vwaconsole('total items: '.$items->length); vwaconsole('chunk size: '.$chunk_size); echo'<br>'; /* chunks processing: */ $chunkxml = new DOMDocument(); $chunkxml->formatOutput = true; $chunkxml->preserveWhiteSpace = false; $counter = 0; $chunkroot = null; foreach($items as $item) { //vwaconsole('processing item'); if ($chunkroot === null) { $chunkroot = $chunkxml->createElement('root'); $chunkxml->appendChild($chunkroot); //vwaconsole('created root'); } if (($processedamount + $chunk_size) > $items->length) { //vwaconsole("last chunk in progress..."); $islast = 1; } $chunkitem = $chunkxml->createElement($item->nodeName); $chunkroot->appendChild($chunkitem); //vwaconsole('appended child item to root'); foreach($item->childNodes as $spec) { //vwaconsole('processing specs in item'); $chunkspec = $chunkxml->createElement($spec->nodeName); $chunkitem->appendChild($chunkspec); $chunkspectext = $chunkxml->createTextNode($spec->nodeValue); $chunkspec->appendChild($chunkspectext); } $counter++; $processedamount++; if ($counter >= $chunk_size) { $chunkxml->save("wp-content/uploads/wpallimport/files/chunks_bast/bast_chunk_".$loopcount.".xml"); vwaconsole("saved array chunk"); $output = `php export_filter_chunk_processor.php $loopcount $islast `; vwaconsole($output); vwaconsole("creating new array chunk"); $chunkxml = new DOMDocument(); $chunkxml->formatOutput = true; $chunkxml->preserveWhiteSpace = false; $loopcount++; $counter = 0; $chunkroot = null; } if ($items->length === $processedamount) { $chunkxml->save("wp-content/uploads/wpallimport/files/chunks_bast/bast_chunk_".$loopcount.".xml"); vwaconsole("finished saving last chunk"); } } // merge documents later.. /* $newxml = new DOMDocument("1.0", "utf-8"); $newxml->formatOutput = true; $newxml->preserveWhiteSpace = false; $itemContainer = $newxml->createElement('aanbiedingen'); $newxml->appendChild($itemContainer); //$newxml->save("wp-content/uploads/wpallimport/files/TEMP_Bastiaansen.xml"); */ vwaconsole("main ending"); exit(); } else { //vwaconsole("xml is empty ?! exiting"); exit(); } ?>
Export chunk processor: The xml was split by the previous script. This one takes one of the chunks and calls get_headers() , sending a link containing a query multiple of this script run at same time. The queries are then picked up by the last php file. <?php //ini_set('max_execution_time', 10); // console function vwaconsole($input) { $disabled = false; if ($disabled === false) { $a = print_r($input.'</br>'); $a = $input; echo "<script>console.log( '--log--: " . $a . "' );</script>"; } } //end console //echo'<br>'; print_r("called chunk processor > Chunk processor started. "); //echo'<br>'; $loopcount=$argv[1]; $islast=$argv[2]; if ($loopcount === null || $islast === null) { print_r("CHUNK PROCESSOR ERROR > loop count is empty"); exit(); } else { print_r("CHUNK PROCESSOR variables set. loop count: ".$loopcount." is last: ".$islast."<br>"); } if ( ! defined('BAST_ROOT_DIR') ) { define('BAST_ROOT_DIR', __DIR__); } $home = constant( 'BAST_ROOT_DIR' ); $xml_path = $home."/wp-content/uploads/wpallimport/files/chunks_bast/bast_chunk_".$loopcount.".xml"; if (fopen($xml_path,"r") != true) { print_r("chunk file was not found at path: ".$xml_path); exit(); } $xmlChunk = new DOMDocument(); //$xmlChunk = new DOMDocument(); $xmlChunk->formatOutput = true; $xmlChunk->preserveWhiteSpace = false; $xmlChunk->load($xml_path); if (empty($xmlChunk)) { print_r("chunk data is empty, exiting"); exit(); } else { print_r("got chunk data <br>"); } $xpath = new DOMXpath($xmlChunk); $item = $xpath->query("//root//item"); //$items = $xmlChunk->getElementsByTagName('//root//item'); foreach ($item as $node) { echo'new item: <br>'; foreach ($node->childNodes as $spec) { //vwaconsole("processing spec: ".$spec->nodeName); if (($spec->nodeName == 'itemlink')) { $memValue = $spec->nodeValue; //setting new url spec node $spec->nodeValue = processItemLink($memValue); // add new itemfoto nodes to xml } elseif(($spec->nodeName == 'itemfoto1')) { $memValue = $spec->nodeValue; $imgurls = array(); $first = true; for ($i = 1; $i < 50; $i++) { if ($first === false) { $memValue = str_replace('bast_get_itemfoto_id='.strval($i-1), 'bast_get_itemfoto_id='.strval($i), $memValue); } vwaconsole("trying to get a itemfoto with id: ".strval($i)." link: " .$memValue); $triedFotoUrl = processItemLink($memValue); vwaconsole("tried url: ".$triedFotoUrl); if($triedFotoUrl !== $memValue) { $imgurls[] = $triedFotoUrl; } else { vwaconsole("tried url and processed url are equal. end of loop. No new images left or error happened."); break; } $first = false; } //remove the old single itemfoto from xml $spec->parentNode->removeChild($spec); // add sorted nodes from image array if (!empty($imgurls)) { sort($imgurls, SORT_NATURAL); print_r('<br> after sort;'); print_r($imgurls); print_r('<br>'); $arlength = count($imgurls); for($x = 0; $x < $arlength; $x++) { $newItemFoto = $xml->createElement('itemfoto'.strval($x+1)); $newItemFotoText = $xml->createTextNode($imgurls[$x]); $newItemFoto->appendChild($newItemFotoText); $node->appendChild($newItemFoto); } unset($imgurls); } } } echo'<br>'; } //returns string url //follow the query url from xml, return a direct link or returns input on failure. query is processed in Bastiaansen.php. function processItemLink($url) { if (!empty($url)) { $headers = get_headers($url, 1); if(!empty($headers['Location'])) { vwaconsole('test returning header location: '.$headers['Location']); return $headers['Location']; } else { vwaconsole("header empty ?!?! can't convert query"); } } return $url; } $xmlChunk->save("wp-content/uploads/wpallimport/files/chunks_bast/bast_chunk_test_".$loopcount.".xml"); ?>
When the chunk processor calls a query link with get_headers(), the query will be noticed by the next script, the query converter: <?php if ( ! defined('ABSPATH') ) { require_once( dirname( __FILE__ ) . '/wp-load.php' ); } // ---- vars $machineID = $_GET['bast_get_machine_id']; $itemlink = $_GET['bast_get_itemlink']; $itemfoto_id = $_GET['bast_get_itemfoto_id']; if (!empty($itemlink)) { $request = 'bast_get_itemlink'; $value = $itemlink; } elseif (!empty($itemfoto_id)) { $request = 'bast_get_itemfoto_id'; $value = $itemfoto_id; } // ---- end vars if (empty($machineID)) { echo 'please enter query ?bast_get_machine_id=(number) first'; exit(); } if (empty($request) || empty($value)) { echo 'Valid query request would be: bast_get_itemlink <br>'; echo 'Valid query request would be: bast_get_itemfoto_id <br>'; exit(); } // register custom query options function sm_register_query_vars( $vars ) { // get the right custom field names $vars[] = $request; $vars[] = 'pa_'.$request; return $vars; } add_filter( 'query_vars', 'sm_register_query_vars' ); //returns null or string url function fetch($machineID,$request,$value) { $return = null; $args = array( 'orderby' => 'meta_value_num', 'meta_key' => 'bast_get_machine_id', 'meta_type' => 'NUMERIC', 'post_type' => 'product', 'posts_per_page' => -1, 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'bast_get_machine_id', 'type' => 'NUMERIC', 'value' => $machineID, 'compare' => 'EXISTS', ) ) ); $wp_query = new WP_Query($args); if ( $wp_query->have_posts() ) { while ( $wp_query->have_posts() ) { $wp_query->the_post(); apply_filters( 'the_content', 'filter_post_content' ); echo 'found product " '.get_the_title().' " on machine ID '.$machineID.'<br>'; echo 'requested: '.$request.'<br>'; if ($request === 'bast_get_itemlink') { // product url $return = get_permalink(get_the_ID()); break; } elseif ($request === 'bast_get_itemfoto_id') { // image attachment $attachments = get_posts(array( 'post_type' => 'attachment', //'post_mime_type' => 'image', 'posts_per_page' => -1, 'post_parent' => get_the_ID() //'exclude' => get_post_thumbnail_id() )); // as the requested value should be 1, but the array starts at 0.. remove 1 from value if (!empty($attachments) && ($attachments != false) && !empty($attachments[$value-1]) && ($attachments[$value-1] != false) ) { $return = wp_get_attachment_image_src( $attachments[$value-1]->ID, 'full')[0]; echo 'attachment found'; } else { echo 'attachment empty...'; } echo 'total amount of images found on this machine: '.count($attachments); break; } break; } /* Reset Post Data after loop */ wp_reset_postdata(); } else { echo 'query on machine ID '.$machineID.' found no product. Exit.'; } return $return; } function filter_post_content( $content ) { // Check if we're inside the main loop in a single post page. if ( is_single() && in_the_loop() && is_main_query() ) { return $content; } return $content; } $finaldestination = fetch($machineID,$request,$value); if (empty($finaldestination)) { exit(); } //echo 'destination set: '.$finaldestination.'<br>'; header("Location: ".$finaldestination, true, 302); ?>
I send off this: <?php $data = "<egateway> <eCardExpiryMonth>01</eCardExpiryMonth> <eCardExpiryYear>04</eCardExpiryYear> <eCardHoldersName>Joe Bloke</eCardHoldersName> <eCardNumber>4444333322221111</eCardNumber> <eCVN>123</eCVN> <eTotalAmount>100</eTotalAmount> </egateway> "; $ch = curl_init(); curl_setopt($ch, CURLOPT_POSTFIELDS, $edata); curl_setopt($ch, CURLOPT_URL, "https://www.example.com/gateway_cvn/testpage.asp"); curl_exec($ch); curl_close($ch); ?> In return, I get the following XML: Code: [Select] <eResponse> <eTrxnStatus>True</eTrxnStatus> <eTrxnNumber>20219</eTrxnNumber> <eAuthCode>123456</eAuthCode> <eReturnAmount>100</eReturnAmount> <eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError> </eResponse> Is there a way to make it so this does not show, and instead I can make PHP do something like: if (eTrxnStatus == True) {// do stuff}; ? Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. Hello there, I have a problem with this project I'm working on, everything is working fine except for one last thing. it goes as you go to the website, search for a city, choose a hotel from a list in that city, then book a room in that hotel, go to confirmation page then to paypal. everything is fine except after the booking when you go to the confirmation page, it shows correctly the number of nights you booked and everything, all except the rooms, it shows 0 rooms selected, and it doesn't give any price at all. here is the code Code: [Select] <?php include("db.class.php"); class hotelManager { public function getHotel($where) { $where = isset($_POST['where']) ? $_POST['where'] : ""; $dbObj = new DB(); $where = $_POST['where']; $sql = "select * from hotels where city_id IN (select id from cities where name = '$where') or country_id IN (select id from countries where name = '$where')"; $result = mysql_query($sql); $arr = array(); echo "<table>"; while($row = mysql_fetch_array($result) or die(mysql_error())) { echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid'"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\"> <a href=\"hotels.php?id=".$row['id']."\" class=\"titleslink\">".$row['name']."</a> </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> </table>"; echo "</td>"; echo "</tr>"; } echo "</table>"; //return $arr; // array of arrays } /*************************** GET ONE HOTEL *****************************/ public function getHotelbyID($hotelID) { $dbObj = new DB(); $result = mysql_query("select * from hotels where id = '$hotelID'"); return $result; } public function HotelDatatabel($result) { $row = @mysql_fetch_array($result); echo "<table width=98%>"; echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\" class=\"searchtitle\"> ".$row['name']." </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> <tr> <td> ".$row['details']." </td> </tr> <tr> <td> <a href=\"http://".$row['website']."\" class=\"link\">".$row['website']."</a> </td> </tr> </table>"; echo "</td>"; echo "</tr>"; echo "</table>"; } /************************************ GET ROOMS **************************************/ public function getHotelRooms($hotelID) { $result = mysql_query("select * from rooms where hotel_id = '$hotelID'"); echo "<form name='bookingform' id='bookingform' method='post' action='book.php'>"; echo "<input name=\"roomid\" id=\"roomid\" type=\"hidden\" />"; echo "<input name=\"roomnum\" id=\"roomnum\" type=\"hidden\" />"; echo "<input name=\"hotelid\" id=\"hotelid\" type=\"hidden\" value=\"$hotelID\"/>"; echo "<table width=80% >"; echo"<tr>"; echo "<td>Check-in date</td>"; echo "<td>"; echo "<input type=\"text\" name=\"datein\" class=\"date_input\" />"; echo "</td>"; echo "<td>Check-out date</td>"; echo "<td>"; echo "<input type=\"text\" name=\"dateout\" class=\"date_input\" />"; echo "</td>"; echo"</tr>"; echo "<table>"; echo "<table class=\"rooms\" width=100% cellspacing=\"1\" >"; echo "<tr> <th class=\"rooms\">Room Type</th> <th class=\"rooms\">Rate for night</th> <th class=\"rooms\">MAX</th> <th class=\"rooms\">Nr.rooms</th> <th class=\"rooms\">Book</th> </tr>"; while($row = @mysql_fetch_array($result)) { echo "<tr>"; echo "<td class=\"text\" align=center>".$row['room_type']."</td>"; echo "<td class=\"text\" align=center>".$row['price_per_day']."</td>"; echo "<td class=\"text\" align=center>".$row['people']." People</td>"; echo "<td class=\"text\" align=center>"; ?> <select name="nrooms" id="nrooms" onchange=" //alert('<?php echo $row['id'] ; ?>'); //alert(this.value); var exist = 0; if(roomids.length > 0) { for(var hh = 0;hh < roomids.length; hh++) { if(roomids[hh] == <?php echo $row['id'] ; ?>) { exist = 1; //alert(hh); roomnumar[hh] = this.value; } } if(exist == 0) { roomids.push(<?php echo $row['id'] ; ?>); roomnumar.push(this.value); } } else { roomids.push(<?php echo $row['id'] ; ?>); roomnumar.push(this.value); } document.bookingform.roomid.value = roomids; document.bookingform.roomnum.value = roomnumar; "> <option value=0> 0 </option> <?php for($i = 0; $i < $row['available_rooms']; $i++) { $nr = $i+1; $pr=$nr * $row['price_per_day']; echo "<option value=$nr>$nr ($pr\$)</option>"; } echo "</select> </td>"; echo "<td align=center> </td>"; echo "</tr>"; echo "<tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>"; } echo "<tr class=\"rooms\"> <td colspan=\"4\"> </td> <td align=center><input type=\"submit\" value=\"book\" id=\"bookroom\" name=\"bookroom\"/></td> </tr>"; echo "</table>"; echo "</form>"; print_r($_SESSION['order']); $_SESSION['order']=0; unset($_SESSION['order']); } } ?> BookinManager.php Code: [Select] <?php include("hotelsManager.php"); ?> <?php include("config.php"); ?> <?php include("textManager.php"); ?> <?php function echoPostedData() { $dbo = new DB(); $hotelObj = new hotelManager(); $hotelID = $_POST['hotelid']; $datein = $_POST['datein']; $dateout = $_POST['dateout']; $roomid = $_POST['roomid']; $pr = $_POST['pr']; $_SESSION['hotelID'] = isset($_POST['hotelid']) ? $_POST['hotelid'] : $_SESSION['hotelID']; $_SESSION['datein'] = isset($_POST['datein']) ? $_POST['datein'] : $_SESSION['datein']; $_SESSION['dateout'] = isset($_POST['dateout']) ? $_POST['dateout'] : $_SESSION['dateout']; $_SESSION['roomid'] = isset($_POST['roomid']) ? $_POST['roomid'] : $_SESSION['roomid']; $roomsarray = explode(",",$_POST['roomid']); $_SESSION['roomsarray'] = isset($_POST['roomid']) ? explode(",",$_POST['roomid']) : $_SESSION['roomsarray']; $roonsNo = $_POST['nrooms']; $_SESSION['nrooms'] = isset($_POST['roomnum']) ? explode(",",$_POST['roomnum']) : $_SESSION['nrooms']; /********************** hotels ************************/ /******************************************************/ echo "<table width=95% border=0 align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td valign=\"top\">"; echo "<table>"; echo "<tr>"; echo "<td valign=top>"; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='".$_SESSION['hotelID']."' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td>"; $result=$hotelObj->getHotelbyID($_SESSION['hotelID']); $row = mysql_fetch_array($result); echo "<table>"; echo "<tr><td valign=top><strong class=subtitle3>".$row['name']."</strong></td></tr>"; echo "<tr><td class=text valign=top>".$row['location']."</td></tr>"; echo "<tr><td class=text valign=top>check-in Date: ".$_SESSION['datein']."</td></tr>"; echo "<tr><td class=text valign=top>check-out Date: ".$_SESSION['dateout']."</td></tr>"; echo "<tr><td class=text valign=top>"; $newdate = $_SESSION['dateout'] - $_SESSION['datein']; $totalprice = array_sum($_SESSION['totalprice']) echo "</td></tr>"; echo "<tr><td class=text valign=top>Total Price: ".$totalprice."</td></tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td></tr></table>"; } function echoForm2() { ?> <form id="userDetails" name="userDetails" action="" method="post"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top" class="subtitle3"><strong>Your Name</strong><br /> <input type="text" name="name" size="50" /></td> </tr> <tr> <td valign="top" class="subtitle3"><strong>Email address</strong><br /> <input type="text" name="email" size="50" /> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td valign="top" class="subtitle3"> <?php $roomsarray = explode(",",$_POST['roomid']); $roonsNo = explode(",",$_POST['roomnum']); for($i = 0;$i<count($roomsarray);$i++) { if($roonsNo[$i] > 1) { for($j = 0;$j<$roonsNo[$i];$j++) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name </strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } else { if($roonsNo[$i] != 0) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name</strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } } ?> <hr> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit" id="submit" value="Make the reservation" /> </td> </tr> </table> </form> <?php } ?> Code: [Select] <?php include("includes/bookinManager.php"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <th align="left" valign="top" class="formtable"> Booking Data </th> </tr> <tr> <td valign="top"> </td> </tr> <tr> <td valign="top"> <?php echoPostedData(); ?> </td> </tr> <tr> <td valign="top"> </td> </tr> </table> </td> </tr> <tr> <td valign="top"><img src="images/spacer.gif" width="28" height="10" /></td> </tr> <tr> <td valign="top"> <?php if(isset($_POST['bookroom'])) {?> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <th align="left" valign="top" class="formtable"> Your Details </th> </tr> <tr> <td valign="top" > <form action="book.php" method="post" id="payPalForm"> <table width="60%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <td>First name :</td> <td><input type="text" name="first_name" /></td> </tr> <tr> <td>Last name :</td> <td><input type="text" name="last_name" /></td> </tr> <tr> <td>Email address :</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Full guest name :</td> <td><input type="text" name="full" /></td> </tr> <tr> <td>Address :</td> <td><INPUT type="text" NAME="address1" VALUE=""/></td> </tr> <tr> <td>Special Requests :</td> <td><input type="text" name="special" /></td> </tr> </table> </td> </tr> <tr> <td valign="top"> <?php //echoForm2(); ?> <input type="hidden" name="item_number" value="<?php echo $row['id']; ?>"> <input type="hidden" name="cmd" value="_ext-enter"> <input type="hidden" name="redirect_cmd" value="_xclick"> <input type="hidden" name="business" value="tarek_1305896294_biz@gotharious.com"> <input type="hidden" name="item_name" value="Standard Room: Dar El Masyaf Hotel : 2 nights : 9th, july, 2011"> <input type="hidden" name="currency_code" value="USD"> <INPUT TYPE="hidden" NAME="first_name" VALUE="Tarek"> <INPUT TYPE="hidden" NAME="last_name" VALUE="Sabrouty"> <INPUT TYPE="hidden" NAME="address1" VALUE="9th Popastes St."> <INPUT TYPE="hidden" NAME="address2" VALUE="Cleopatra Hamamat"> <INPUT TYPE="hidden" NAME="city" VALUE="Alexandria"> <INPUT TYPE="hidden" NAME="Country" VALUE="Egypt"> <INPUT TYPE="hidden" NAME="lc" VALUE="US"> <INPUT TYPE="hidden" NAME="email" VALUE="tarek@gotharious.com"> <INPUT TYPE="hidden" NAME="night_phone_a" VALUE="+20166005733"> <INPUT TYPE="hidden" NAME="amount" VALUE="100.00"> <?php $roomsarray = explode(",",$_POST['roomid']); $roonsNo = explode(",",$_POST['roomnum']); for($i = 0;$i<count($roomsarray);$i++) { if($roonsNo[$i] > 1) { for($j = 0;$j<$roonsNo[$i];$j++) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name </strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } else { if($roonsNo[$i] != 0) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name</strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } } ?> <input type="submit" name="Submit" value="Submit"> </form> <tr> <td valign="top"> </td> </tr> </table> <?php } ?> Hello everyone, I'm working on an account update page where users can update their email address, password, or security question/answer as desired. The way I currently have it set up is so that only the information that the user enters will be updated in the database. So if they only enter a new email address, the email field in the database is updated and all other fields are left as is. I'm also trying to set a javascript even handler (onUnload) depending on whether or not anything was updated. When their info is successfully updated, I want to alert the user accordingly, as well as when no information was updated. To do this, I have a variable "$updated" that is set at "false" by default and is supposed to be set to "true" when something is updated and "none" when nothing is updated. The form and mysql commands are working and the correct fields are being updated as expected. The problem that I'm having is the $updated variable is not being set correctly and is ALWAYS being set to "true", even when it is expect to be set to "none." Here's the code that I have: Code: [Select] <?php function safe($value){ return mysql_real_escape_string($value); } $updated = "false"; if (isset($_POST['submit'])) { // If the form has been submitted. $newemail = $_POST['newemail']; $pword1 = $_POST['pword']; $question = safe($_POST['question']); $answer = safe($_POST['answer']); $updated = $_POST['updated']; $pword = md5($pword1); $q = mysql_query("SELECT * FROM `signin` WHERE email = '$newemail'") or die (mysql_error()); $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r == 1 && $email == $newemail) { $noemail = "true"; } elseif ($r == 0) { $noemail = "true"; } else { $noemail = "false"; } if ($newemail != "" && $pword1 == "" && $question == "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } elseif ($newemail == "" && $pword1 != "" && $question == "0") { mysql_query("UPDATE `signin` SET `pword` = '$pword' WHERE email = '$email'") or die (mysql_error()); $updated = "true"; } elseif ($newemail == "" && $pword1 == "" && $question != "0") { mysql_query("UPDATE `signin` SET `question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $updated = "true"; } elseif ($newemail != "" && $pword1 != "" && $question == "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail',`pword` = '$pword' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } elseif ($newemail != "" && $pword1 == "" && $question != "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail',`question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } elseif ($newemail == "" && $pword1 != "" && $question != "0") { mysql_query("UPDATE `signin` SET `pword` = '$pword',`question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $updated = "true"; } elseif ($newemail != "" && $pword1 != "" && $question != "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail',`pword` = '$pword',`question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } else { $updated == "none"; } } ?> //This is where the event handler (onUnload) is set according to what has occurred in the code above <?php if (isset($_POST['submit']) && $updated = "true") { echo "<body onUnload=\"alert('Your information has been successfully updated.')\">"; } elseif (isset($_POST['submit']) && $updated = "false") { echo "<body onUnload=\"alert('There have been no updates made to your account information.')\">"; } else { echo "<body>"; } ?> Can anyone see a problem with this and why the $updated variable is not being set as expected. Any ideas on a better way to accomplish what I want to do? Thanks in advance for anyone's help! I'm using PHP 5.2.14 under Windows XP. I'm trying to use ini_set to turn on the 'track_error' configuration option, and it's not working. I make this call, $xxx = ini_set('track_error',"1"); and it returns false. According to the documentation, track_error can be set from any source (including ini_set). What could prevent that from happening? Going back one step, I want to set track_errors so that I can fetch and process the error which occurs when mysql_connect fails. Since it fails, it returns no link, making it impossible to call mysql_errors. Whether ini_set can be made to work or not, is there another, perhaps better way to accomplish this? Hello I want to check that a variable the user enters is not empty and that it is a string (no numbers). Here is what i have written: Code: [Select] <?php include('css/layout.css.php'); include('css/menu.css'); if (isset($_POST['submit'])) { include('includes/dbconn.php'); if (is_string($_POST['name']) && strlen($_POST['name']) > 0) { $name = mysql_real_escape_string($_POST['name']); } else { echo "Category name must be a word!<br />"; } if (isset($name)) { echo $name; } else { echo "something"; } } ?> and this is the form i'm getting the data from: Code: [Select] <form action="category_add.php" method="post"> <table class="table-view"> <tr> <td><label for="name">Category Name</label></td> <td><input type="text" name="name" id="name"></td> </tr> <tr> <td><input type="submit" value="Save changes" name="submit" id="submit"></td> </tr> </table> </form> If i enter nothing it works fine, if i enter a string it also works fine, the problem is when i enter 123 in the textbox, i dont get the "Category name must be a word!" as i expected i would. Could someone help me with this one please? Thanks in advance. Hello, this is my first post in this forum, in fact my first post about php. I am developing a crud application, but when i am trying to list a set of results it gives me more that the expected Let me explain. if i print_r my array (which i get it from a sql result) it gives me this Array ( => SHR1 [codprod] => SHR1 [1] => REGULAR SERVICE HOUR [proddescription] => REGULAR SERVICE HOUR [2] => 3.00 [qty] => 3.00 [3] => HR Code: [Select] => HR [4] => 45.0000 [price] => 45.0000 [5] => 0.00 [discount] => 0.00 [6] => 135.00 [amount] => 135.00 ) [/li][/list] if I foreach($detailrow as $value){ echo $detailrow['codprod'] . ", " . $detailrow['proddescription'] . ", " . $detailrow['qty'] . ", " . $detailrow['code'] . ", " . $detailrow['price'] . ", " . $detailrow['discount'] . ", " . $detailrow['amount'] . "<br/>"; } It gives me 14 rows with the same info. I run the query in mysql and it gives me only 1 result as expected. I noticed that the 14 rows are the same quantity of items in the array not results but let say columns, i dont know if it has something to do with the results. My questions: Why it is giving me 14 rows instead just one? What is the $value in the foreach function? why can't i just say foreach($myarray)? why the print_r shows me the items array duplicated using the array position and the item name? Thank you for your help!! I have an avatar upload script. The uploading and moving of the image file to the correct directory works fine, but the displaying of the image causes problems. This is the code that is supposed to display the avatar. // _DISPLAY_ avatar - START $query2 = "SELECT * FROM user WHERE user_id = '$dbuser_id'"; $row2 = mysqli_query ($dbc, $query2) or die (mysqli_error($dbc)); $assoc2 = mysqli_fetch_assoc ($row2); $target = AVATAR_UPLOADPATH; $avatar_name = $target . $assoc2['avatar']; if (is_file($assoc2['avatar'])) { echo "<img src='$avatar_name' alt='Avatar' /><br /><br />"; } else { echo "is not a regular file"; } // END The avatar column in the MySQL database says: image.jpg So there's a regular file. What I want to accomplish: I want the script to check if there's an avatar in the database, if NOT, then it should say: "no avatar uploaded yet." But as it is now it's telling me that there's no regular file even if there is, as I said the avatar column has an entry saying: image.jpg. Should I use if !empty instead? The strange thing is it used to work, now for some reason it suddenly doesn't. EDIT: With !empty it works, am I using the is_file function incorrectly? I am trying to load all rows from a table in a database into a table on a webpage. I cannot understand why the following code does not work: Code: [Select] <?php ... echo "You are currently in a fleet. The details of the fleet are below.<br>"; $fleetName = $_SESSION['charFleetName']; $sqlFleetDetails = "SELECT * FROM `$fleetName`"; $queryFleetDetails = mysql_query($sqlFleetDetails); echo "<table>"; echo "<tr>"; echo "<th>Pilot</th>"; echo "<th>Ship</th>"; echo "<th>Type</th>"; echo "</tr>"; while($rowFleetDetails = mysql_fetch_array($queryFleetDetails)) { $charId = $rowFleetDetails['charId']; $charName = $rowFleetDetails['charName']; $shipHull = $rowFleetDetails['shipHull']; $shipType = $rowFleetDetails['shipType']; echo "<tr>"; echo "<td><a href=\"#\" onClick=\"CCPEVE.showInfo{1377, " . $charId . "}>" . $charName . "</a></td>"; echo "<td>" . $shipHull . "</td>"; if($shipType == 1) echo "<td>Logistics</td>"; if($shipType == 2) echo "<td>DPS Boat</td>"; if($shipType == 3) echo "<td>Sniper 120Km+</td>"; if($shipType == 4) echo "<td>Off-grid Booster</td>"; echo "</tr>"; } echo "</table><br>"; I originally had the $rowFleetDetails['charId'] and others in the echo instead of loading them into variables then echoing the variables but changed it to see if that was working, neither is. If I add an extra line outside of the while loop to echo the output of the array then the information is displayed fine, so I know that the information is being transferred from the table into the array correctly, but why is it not outputting properly in the While loop? I have only one result being displayed in a select query result whereas I'm expecting 4 results in an array. This is my code below. $sq2="SELECT course FROM course_reg WHERE userid=?"; $stm =$conn->prepare($sq2); $stm->bind_param("s",$logged); $stm->execute (); $return2= $stm->get_result(); $r2 = $return2->fetch_all(); //print_r($r2); foreach($r2 as $course){ foreach($course as $courses){ echo $courses; } }
If I do print_r($r2); it comes out with array containing all the possible results. When i loop through the array to get individual result, it only comes out with a single result. I.e CME211 I would be glad if you can help me figure where the issue is. Thanks!!!
I have a form on a page that has checkboxes for a number of entities, including one that is new. I want to determine how many checkboxes were checked for the new entity. The html is:
<div id="new" style="display:block;">Which method(s) of valuation would you like to use for this report?<br /> <input type="checkbox" name="method_code['new'][]" value="EE">Excess Earnings<br /> <input type="checkbox" name="method_code['new'][]" value="DCF">Discounted Cash Flow</div> <div id="75" style="display:none;">Which method(s) of valuation would you like to use for this report?<br /><input type="checkbox" name="method_code['75'][]" value="EE" checked="checked" >Excess Earnings<br /> <input type="checkbox" name="method_code['75'][]" value="DCF" checked="checked" >Discounted Cash Flow</div><div id="79" style="display:none;">Which method(s) of valuation would you like to use for this report?<br /> <input type="checkbox" name="method_code['79'][]" value="EE">Excess Earnings<br /><input type="checkbox" name="method_code['79'][]" value="DCF">Discounted Cash Flow</div> <div id="77" style="display:none;">Which method(s) of valuation would you like to use for this report?<br /> <input type="checkbox" name="method_code['77'][]" value="EE">Excess Earnings<br /> <input type="checkbox" name="method_code['77'][]" value="DCF">Discounted Cash Flow</div>I looked for a method of counting the nuber of checked boxes for a given entity and found So, to count only non-empty: count(array_filter($array));here and here So I implemented that in my code and it doesn't work. I put in the following to debug: echo '<pre>'; print_r($_POST['method_code']); echo '</pre>'; echo "arraycount ".count(array_filter($_POST['method_code']['new']));die();and I get the following output: Array ( ['new'] => Array ( [0] => EE ) ['75'] => Array ( [0] => EE [1] => DCF ) ['78'] => Array ( [0] => EE ) ) arraycount 0Why is the count 0? I expect that count(array_filter($_POST['method_code']['new'])) would be one since there is one element in that array. Hello.
I'm having some issues with a select statement containing ABS().
Here's the select query:
"SELECT gadenavn, husnr, ABS(husnr - $husnr) AS husnr_range, postnr,db, shaping, dsl_node, ctr_node, db_ctr_luftlinje, bynavn FROM `TABLE 1`, Post_numre WHERE `postnr`=`postnummer` AND `gadenavn`=`$vejnavn` AND `postnr`=`$postnr` AND `husnr`>0 ORDER BY husnr_range ASC LIMIT 5"Now lets asume my variable "$husnr" is a value of 15. In my table I have the values for coulmn "husnr": 13,12,11,10,9 What really bugs me is the outcome doing af simple "while loop" is returning the values 12,11,10,9. What happened to 13?! printing the "husnr_range" values shows "3,4,5,6". What puzzles is the row missing, as I only get 4 results, with a "LIMIT 5". Can anyone explain why the last resulst isn't included? Hi all,
Wondered if anyone could assist?
On the following website the footer is not displaying as expected and cannot see why:
http://www.urxltd.com/index.php
Any other pages on the website show the footer correctly.
Thanks.
Hello guys, I devised the code block below, to retrieve all US zip codes that are located within a specified radius from the user's own zip code. So basically, the user selects a maximum distance option from a form element (not shown here)which is appended to the variable $distance. What the code below does is as follows: The longitude and latitude corresponding to the user's zip code are retrieved in the first query. Then in the second query, the longitudes and latitudes corresponding to every zip code in the database are retrieved. In the ensuing while loop, a distance calculation is made between the user's zip and every other zip using the longitudes and latitudes and if that distance falls within the selected $distance, that particular zip code is listed in a defined array called $range. Now everything works fine up to this point as tested. The problem is with the very last line. I try to implode the $range array into a string with the same name, separating the array elements with commas (,). Then when I print out the resulting string, I get the list of desired zip codes but not separated by commas. For example: 9001190015900179003490037900439004790048900569006 19006290301 9030190301 90302 Well when I use a foreach loop as follows: foreach ($range as $r) {echo $r.",";} the $range array behaves like any normal array yielding: 90011,90015,90017,90034,90037,90043,90047,90048,90056,90061,90062,90301 ,90301,90301 ,90302, So why in the world is the implode function not working? Here is my code. //Retrieve the zip codes within range. // Connect to the database. require('config.php'); //Retrieve longitude and latitude of logged in member. $query = "SELECT* FROM members INNER JOIN zip_codes ON members.zip = zip_codes.zip WHERE members.member_id = '{$_SESSION['id']}'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $my_lon = $row['lon']; $my_lat = $row['lat']; //Query all longitudes and latitudes in database. $query2 = "SELECT* FROM zip_codes INNER JOIN members ON members.zip = zip_codes.zip "; $result2 = mysql_query($query2); while ($row2 = mysql_fetch_assoc($result2)) { //Define array to hold zips found within range. $range = array(); if((rad2deg(acos(sin(deg2rad($my_lat))*sin(deg2rad($row2['lat'])) +cos (deg2rad($my_lat)) * cos (deg2rad($row2['lat'])) * cos(deg2rad($my_lon - $row2['lon'])) ) ) )*69.09 <= $distance ) { $range[] = $row2['zip']; } //Implode the range arrary. $range = implode(',' , $range); echo $range; }//End of while loop. I am doing some study on using time() and date() and i just wrote this simple for loop to add one day to each iteration with +$i and its echoing the unix timestamp as opposed to the correctly formated date as it should be based on my code. Anyone have any idea why this is not working as expected? for($i=0; $i < 50; $i++) { echo $time = time()+$i . "<br />"; // add a day on each iteration echo date('y-m-d', $time) . "<br />"; // should echo 10-12-02, 10-12-03, 10-12-04, etc.. } what am i doing wrong here? arrgggg! maybe its too late for this s$%^#! I cannot get this INSERT to work. Not records are being added to the sys_city_dev table. No query errors are being thrown. I am simply trying to add ALL records from all_illinois to sys_city_dev and Mid should have be add as 11 in all inserts. city_name of course will be field city_name from all_illinois. Here is my code: $query = "SELECT * FROM all_illinois"; if ($results = mysqli_query($cxn, $query)) { $row_cnt = mysqli_num_rows($results); echo $row_cnt . " Total Records in Query.<br /><br />"; if (mysqli_num_rows($results)) { while ($rows = mysqli_fetch_array($results)) { echo $rows['city_name'] . "<br />"; $mid_id = '11'; $insert_city_query = "INSERT INTO sys_city_dev (ID, Mid, cityName, forder, disdplay, cid) VALUES (' ','" . $mid_id . "','" . $rows['city_name'] . "', '', '','')"; if (!$insert_city_query) exit(mysql_error()); } } } Here is my insert table structure and 5 records dump: -- -- Table structure for table `sys_city_dev` -- CREATE TABLE IF NOT EXISTS `sys_city_dev` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev` -- INSERT INTO `sys_city_dev` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'Dothan', 0, 0, 0), (84011, 1, 'Alabaster', 0, 0, 0), (84012, 1, 'Birmingham', 0, 0, 0), (84013, 2, 'Flagstaff', 0, 0, 0), (84014, 1, 'Auburn', 0, 0, 0); And the all_illinois dump w/ 5 records: -- -- Table structure for table `all_illinois` -- CREATE TABLE IF NOT EXISTS `all_illinois` ( `state_id` varchar(255) NOT NULL, `city_name` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `all_illinois` -- INSERT INTO `all_illinois` (`state_id`, `city_name`) VALUES ('135', 'Abingdon'), ('135', 'Adair'), ('135', 'Addieville'), ('135', 'Addison'), ('135', 'Adrian'); Here is my function which almost works as expected: <?php function find_value($array,$value) { for($i=1;$i<sizeof($array);$i++) { if($array[$i] == $value) { echo "$i . $array[$i]<br />"; return; } } } ?> And I call the function like so: <?php $names = array('Jason','Mike','Joe'); $name = 'Joe'; find_value($names,$name); ?> And the output is: 2 . Joe According to my understanding of Arrays, Joe would be index 3 BECAUSE my counter starts at 1 in my for loop??? Why is the result like this? What am I not understanding here? I created a function called converter. My code doesn't look like it processes anything after the first if . This is what is displayed in browser. Convert a String original string: roses Are red, violets are blue.... converted string: roses are red, violets are blue.... converted string: roses are red, violets are blue.... converted string: roses are red, violets are blue.... <html> <head> <title>Create a PHP Function to Convert a String</title> </head> <body bgcolor="pink"> <h2>Convert a String</h2> <?php $phrase = "roses Are red, violets are blue...."; function converter($arg1, $arg2){ if($arg1="lower"){ return strtolower($arg2); } elseif ($arg1="upper"){ return strtoupper($arg2); } else /* if($arg1="title")*/{ return ucwords($arg2); } } print "original string: ".$phrase."<br />"; print "converted string: ".converter("upper",$phrase)."<br />"; print "converted string: ".converter("lower",$phrase)."<br />"; print "converted string: ".converter("title",$phrase)."<br />"; ?> </body> </html> I have a problem with the below code: Code: [Select] <?php $sql_ranks = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, teams.team_name, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking, teams WHERE vtp_members.team_id=".$_GET['t']." AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date > '$last_sunday' AND vtp_tracking.action_date < '$next_sunday' GROUP BY teams.team_name ORDER BY surfs DESC"); $rsranks = mysql_query($sql_ranks); echo "<br><table align='center' valign='top' border='0' width='300px'> <tr><td colspan='2' align='center'><font size='2px'><b>Team Rankings (Current Week)</b></font></td></tr> <tr><td><font size='2px'><b>Team</font></td><td align='right'><font size='2px'>Total Surfs</font></td></tr>"; while ($row = mysql_fetch_array($rsranks)) { echo "<tr><td><font size='2px'><b>".$row[team_name]."</font></td><td align='right'><font size='2px'>".$row[surfs]."</font></td></tr>";} echo "</table>"; ?> Problem is that the last output (".$row[surfs].") is the same for all teams. It seems it is not making a total of all id's and not per team_name. anyone can see what I am doing wrong. I need to sort by team_name and the surfs should display the total of the members with team_id is ".$_GET['t']." |