PHP - Stuck With A Loop Problem
Hello folks!
I have a mysql table with questions and another one with multiple choice answers. The common key is QuestionID. Some questions have 2 answers, some 3, and some 4. I can display a list of all questions on my page but I am unable to display the related answers below them. I have been trying since yesterday but I just can't get it right. It seems to be a loop related problem. Could you give me any pointers? Thank you! John Similar TutorialsHi all ! A WHILE loop in a FOR loop problem Script about links and sublinks from 1 table. In fact 2 questions about that. 1) In the FOR loop I have for example to do the loop 3 times. (needs to find 3 results withing the loop with if and else) When first time, he's gonna search within the WHILE loop that holds (for example) 10 records of the DB in a variable. He needs to search for rowid number 5, he found it He goes out of the WHILE loop and goes searching again but now for rowid number 2 Now it seem that the WHILE loop start searching for number 2 but won't start from his first row in the variable (10 rows from the db ). He start at row number 6 instead of beginning all over again !!! -> so the order of the numbers of rows MUST be in an ascending order, ortherwise he won't find them all ! But the numbers I have are NOT in an ascending order !!! Why doesn't the WHILE loop begin again from his row 1 in the variable ? FOR loop { WHILE loop { content here, break; } } 2) even when I get all the result in an ascending order, he won't go doing a second search but with a different rowid number that he gets from the FOR loop. It is giving me back indeed the right new rowid number, but the WHILE loop is doing nothing. I have put many echo "..."; and other stuff for checking but can't find the cause ! Here's the code : Code: [Select] // $ResultShow = 10 rows from mysql db if(isset($ResultShow)){ if (mysql_num_rows($ResultShow) >= 1){ //$linksuborder = "2,3,4"; $array1 = explode(",", $linksuborder); sort($array1); for ($n = 0; $n < count($array1); $n++){ // searchin for the right row id in the variable $ResultShow where we find the numbers for next loop $r1 = each($array1); While($Row2 = mysql_fetch_array($ResultShow)) { if($Row2["linkid"] == $r1['value']) // found it, now look for the numbers that we'll put in an array { echo "---here the content---"; // linksuborder is where numbers from row id's are stored like 5,2,8 //now put them in an array $array2 = explode(",", $Row2["linksuborder"]); sort($array2); for ($n2 = 0; $n2 < count($array2); $n2++){ $r2 = each($array2); ////// here searching for the sublinks ////// While ($Row3 = mysql_fetch_array($ResultShow)) { if($Row3["linkid"] == $r2['value']) // search for the right row id within the variable $ResultShow { echo "---here the content---"; break; // found it, so no need to do the rest of the loop } // end if } //end while ////// end searching for sublinks ////// } // end for } // end if else { echo "--- content here ---"; } } // end while } // end for } //end if } // end if Table : linkid linksuborder linktitle 1 2,3,4 2 9,7,8 mainlink1 3 10 mainlink2 4 mainlink3 5 6 7 sublink3 8 sublink2 9 sublink1 10 sublink4 -> linksuborder 2,3,4 are the row id's for the mainlink -> than we put the numbers 9,8,7 (also row id's) mentioned in row linkid 2 also in a new array -> now we can search for the sublinks -> get the details from row linkid 9, than 7, than 8 -> First mainlink is compleet, now go to row linkid 3 to do it all over again for the next mainlink... RESULTS from an sorted array -> sort($linksuborder); ------------------------------------------------------------- mainlink1 : sublink1, sublink2, sublink3 mainlink2 : **no result back but it should * mainlink 3 : **no result back but it should * hi The output of this code is: 1950 1951 1952 .... script Code: [Select] <?php for ($i = 1950; $i < 2012; $i++) { echo "<option value='$i' class='dr'>".$i.'</option>'; } ?> but i need something like: Insert a date 1950 1951 1952 .... how can i solve that? welll. i can do <option value='null' class='dr'> year</option> All,
I am taking the output for every title in my Database and displaying it in a box. Within that box I am providing the opportunity to open another box with further content inside. The problem with the code below is that when you click on the expand button it expands in all the boxes, not just the one you are clicking in. I don't understand why this is happening when everything else is ok - any fixes and explanations are greatly appreciated:
// GOING THROUGH THE DATA if($result->num_rows > 0) { //echo "<hr />"; while($fetch=mysqli_fetch_array($result)) { $title=$fetch['title']; $feed_rss=$fetch['url']; $content_id=$fetch['content_id']; $source_image=$fetch['source_image']; $item_id = $fetch['item_id']; $item_title = $fetch['item_title']; $item_date = $fetch['fetch_date']; $item_description = $fetch['item_description']; $item_url = $fetch['item_url']; ///////////////////////////////////////////////////////////////////////////////// // ?> <div class="box col5"> <?php $query_string = "cid={$content_id}&t={$item_id}&item_title={$item_title}"; $url_query_string = "http://www.disciply.com/article/index.php?" . $query_string; /*Start of dynamic content open*/ echo "<p>$title</p>"; echo "<img src=$source_image />"; echo "<p>item_url = $item_url</p>"; ?> <div class="panel_button" style="display: visible;"><img src="../images/expand.png" alt="expand"/> <a href="#"><?php echo $item_title; ?></a></div> <div class="panel_button" id="hide_button" style="display: none;"><img src="../images/collapse.png" alt="collapse" /> <a href="#">Hide</a> <object type="text/html" data='<?php echo $item_url;?>' width="100%" height="800px" style="overflow:auto;border:5px ridge blue"> </object> </div> </div> Edited by genista, 19 July 2014 - 10:33 PM. This is the email verification script im using.. //email verify $activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand(); $sql="INSERT INTO account_info (activation_key, status) VALUES ('$activationKey', 'verify')"; if (!mysql_query($sql)){ exit('Error: ' . mysql_error()); } else { //Send activation Email $to = $_POST['email']; $subject = "NarutoRPG.com Registration"; $message = "Welcome to our website! You, or someone using your email address, has completed registration at narutoRPG.com. You can complete registration by clicking the following link:\rhttp://www.arzania.com/verify.php?$activationKey\r\r If this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ narutoRPG.com Team"; $headers = 'From: ashyiscool2@gmail.com' . "\r\n" . 'Reply-To: ashyiscool2@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); //User isn't registering, check verify code and change activation code to null, status to activated on success $queryString = $_SERVER['QUERY_STRING']; $query = "SELECT * FROM account_info"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ if ($queryString == $row["activation_key"]){ echo "Congratulations!" . " " . $row["username"] . " is now the proud new owner of a NarutoRPG.com account. Login to begin to play."; $sql="UPDATE account_info SET activation_key = '', status='activated' WHERE (id = $row[id])"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } } } } } include "footer.php"; ?> For some reason, when the person is registered it shows everyones name who registered, for example.. You've been successfully registered!Congratulations! tonyhh is now the proud new owner of a NarutoRPG.com account. Login to begin to play.Congratulations! tonyh is now the proud new owner of a NarutoRPG.com account. Login to begin to play.Congratulations! tony is now the proud new owner of a NarutoRPG.com account. Login to begin to play.etc...etc.. How can you make it only repeat the users name who registered, not everyone? Why does this code only display 1 result? If I PRINT $row3 all results diplay, but the variable will only give 1 result. It would be easier for me to just PRINT row3, but I have 13 rows with different loops. Code: [Select] $sql = "SELECT * FROM $city WHERE SG_Name='$sg GROUP BY ID'"; $result = mysql_query($sql); while ($row = mysql_fetch_row($result)) { $ID="{$row[3]}"; } "<tr border='1'> <td>".$Source_ID."</td> </tr>"; I hate asking help twice in the same day but im really stuck Im having problem with this loop im writing. I'm randomly grabing a name from an array then im checking to make sure it doesnt exist already in the database if it does then it loops back and grabs another name. I'm having problems with seeing whats going on while its looping I inserted a name in the data base to match "AGENA" so if AGENA is the end result i know its not working. right now its not even looping. $planet_names = " AGENA Deneb Zuben Zosma"; $explode_names = explode(" ", $planet_names); $random_key_name = (array_rand($explode_names, 1)); $planet_name = $explode_names[$random_key_name]; $loop_again = 0; while ($loop_again > 1) { $name_check3 = "SELECT address FROM planets WHERE name = '".($planet_name)."'"; $name_check2 = mysql_query($name_check3) or trigger_error("SQL", E_USER_ERROR); $name_check1 = mysql_num_rows($name_check2); if($name_check1 >= "1"){ // checks to see if name exists $loop_again = 1; }else{ ++$loop_again; $planet_name = $planet_name; } } echo "It ran $loop_again times<br />"; echo "$name_check1 match found equals 1. No match found equals 0<br />"; echo $planet_name . "<br />"; Hi guys, I have this code which fetches data from an existing database and reflects the data into a tabular form. Basically what it does is it parses the field portNumber from my table and gets the last two digits of the variable. Then it will highlight in the table all those returned values for portNumber. Here is the code: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Location Mapper</title> <script> function highlightRow(id) { document.getElementById(id).style.backgroundColor = "FFCC00"; } </script> <style> body { font-family:Tahoma, Geneva, sans-serif; font-size:10px; text-align:center; } .unitHere { color:#000; background-color:#0F0; styl } </style> </head> <body> <table width="800" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <th colspan="40" scope="col">SCMST 238</th> </tr> <tr> <?php $conn = mysql_connect("localhost", "root", "123456") or die(mysql_error()); mysql_select_db("orderstatus") or die(mysql_error()); $sql = mysql_query("SELECT * FROM superdome WHERE portNumber LIKE '%238%' AND isHistory='0' ORDER BY portNumber ASC") or die(mysql_error()); if(mysql_num_rows($sql) == 0) { echo "NOTHING FOUND"; } else { $i = 1; while ($i <= 40) { $x = 0; while($result = mysql_fetch_array($sql)) { $resultPortArray = str_split($result['portNumber'],4); $resultPortArray[1]; $x++; } if ($resultPortArray[1] == $i) { echo "<td width=\"20\" height=\"30\" id=\"".$i."\" class=\"unitHere\">".$i."</td>"; $i++; } else { echo "<td width=\"20\" height=\"30\" id=\"".$i."\">".$i."</td>"; $i++; } } } ?> </tr> </table> </body> </html> The problem is my output only highlights the one column in the array returned. The rest are not highlighted. I need help badly. I am trying to loop through a filtered table. This is the code of the loop:
$result = mysqli_query($con,$sql);
$query = "INSERT INTO invoiceitems(invnumber,itemnum,price,quantity) VALUES('$ttinvno','$itemno','$price','$qty')";#,unix_timestamp())";
if ($prebidder != $buser) { } ?> The filtered data has 55 rows of which 28 are unique. I am trying to loop through so that the names ($buser) match the invoice number ($ttinvno). I have the rows indexed on buser descending. But the rows don't seem to want to match correctly. The invoice numbers go in sequence correctly but for instance the first two rows have the same name. But no matter what I have done in this format either the invoice number changes after the first row, or it changes after the third row. I want it to change after the second row. I have tried multiple ways including prematurely defining row and then using mysqli_data_seek($result,0); to reset the result before the loop. Obviously there is a flaw in my code. Can anyone help? Thanks very much in advance!
Hi! I have a code that don't do want I want that to do. <?php $chars = str_split('abc'); $char_len = count($chars); $length = 3; //loop for char_len^length $loop_length = pow($char_len, $length); for($i = 0; $i < $loop_length; $i++) { //convert $a to chars $string = ''; while($a != 0) { $string = $chars[$a % $char_len] . $string; $a = (int) ($a / $char_len); } //pad and print string echo str_pad($string, $length, $chars[0], STR_PAD_LEFT), "<br>\n"; if($loop_length-1 == $i){ $length++; } } ?> And what it do, is to print out all combination of a, b and c. My problem is that when the loop is done (you'll se my if statement) I want to add one on length so it print out a, b and c in four letters. ex abca, abcb. But it isen't working. Have you any clue that can help me? Thank you for your answer. Hi Guys, I am trying update some array values in my database. For some reason using the code below the $checked and $counter values are not working. I have added the echos for debugging purposes and nothing is being echoed. $query = mysql_query("SELECT * FROM offers WHERE seller='$username' AND buyer='$buyer'"); while ($row = mysql_fetch_assoc($query)) { $checked = $_POST['checkbox'][$y]; $counter = $_POST['counter'][$y]; echo $checked; echo $counter; $date = date("Y-m-d"); $time = date("H:i:s"); mysql_query("UPDATE offers SET offer='$counter',seller_status='Counter Offer Made',buyer_status='Counter Offer Received',date='$date',time='$time',seller_action='0',buyer_action='1' WHERE domain='$checked'"); } When i do the following it echos the $checked and $counter values perfectly so i know that the form is posting ok. foreach ($_POST['checkbox'] as $checked) { echo $checked; } foreach ($_POST['counter'] as $counter) { echo $counter; } Can anybody figure out what is wrong with my while loop? Iv been at it for ages and cant seem to crack it. Thanks Hello People. I have a site that I am trying to paste multiple pins on a single map in a wordpress site, using cbxgooglemap plugin and advanced custom fields for my lat and long information. The following code works fine for one pin, on one map. echo do_shortcode('[cbxgooglemap lat="'.get_field('latitude').'" lng="'.get_field('longitude').'" ]'); However, when I try to post it within the loop, I simply get multiple maps, instead of one map, with multiple pins. Here is the code that doesn't work correctly, it gives me 3 maps. <?php $justMap = new WP_Query(array( 'posts_per_page'=> 3, 'post_type' => 'airfield_card' )); while($justMap->have_posts()){ $justMap->the_post(); echo do_shortcode('[cbxgooglemap lat="'.get_field('latitude').'" lng="'.get_field('longitude').'" ]'); } ?> Please can someone tell me how to alter the code so that a single map is outside the loop, but still embedding each pin from the loop.
Kind Regards this foreach loop is causing mysql_num_rows to not return the amount of rows in mysql correctly. the variable $value has two strings in it (testa and testb). So foreach should loop once with $value as 'testa', then loop again with $value as 'testb'. the problem is at the mysql_num_rows. It should return 1 because there is 1 row in mysql with keywords 'testa' and 1 row with keywords 'testb', instead it returns zero. If i change $value to 'testa' it works. Code: [Select] foreach($value as $value) { $updatestable = mysql_query("SELECT * FROM `Stacks` WHERE keywords LIKE '%$value%' ORDER BY id DESC LIMIT 1")or die (mysql_error()); $upnum = mysql_num_rows($updatestable); echo $upnum; if ($upnum==0){ $uporigin=0; } else { while($rowup = mysql_fetch_assoc($updatestable)) { $uporigin = $rowup['origin']; $upreply = $rowup['reply']; } } } hope the question isn't too complicated. basically if i remove the loop. the mysql num_rows works and returns a row. If i don't remove the loop it returns zero. Hello, I have a loop below but the first time the person isn't counted in the if loop... I'm new to php and I know there is something easy I'm missing but I can't see it! Any help you be great. Code: [Select] // loop from mysql reults while($row = mysql_fetch_array( $result )) { echo "Person: ".$row['id']; echo "Earned: ".$row['earned']; //set-up php var's $earnedSum = $row['earned']; $firstPerson = $row['id']; if ($lastPerson == $firstPerson){ $earnedTotal = $earnedTotal + $earnedSum ; // Add's the earn units $lastPerson = $firstPerson; }else{ $earnedTotal = 0 ; // reset $lastPerson = $firstPerson; } echo 'This is the total Earned Result = '.$earnedTotal.'<br>'; } ?> Hello. I was wondering if anyone could please help with a problem I seem to be having a problem with my foreach loops. I have an array that holds other arrays. When I am trying to populate the database tables with the information in each array, things are going horribly wrong. This is my code: $tabledata = $this->db->get('tableinfo'); $i = 0; $_temp = array(); foreach($tabledata->result() as $row) { $data[$i] = $this->callAPI("lateststandings&records=3&category=" . $row->category . "&distance=" . $row->distance_id); array_push($_temp, $row->dbname); $i++; } $j = 0; foreach($data[$j]['Records']['Record'] as $record) { $record['FirstName'] .= " " . $record['LastName']; $this->db->replace($_temp[$j], $record); $j++; }
When this is run 2 things are happening:
1) What I am expecting to happen is, there should be 3 rows added to each table. But only 1 is being added to each table. I am not sure what I am doing wrong in these loops.
These are my tables and fields. student_info(table) contains ( id(PK), student_name) student_subject(table) contains ( id(PK), student_id(FK), subject_name) below is my query: Code: [Select] $getRecords= mysql_query("select student_info.id, student_name, student_subject FROM student_info,student_subject WHERE student_info.id = student_subject.student_id"); while($getresult=mysql_fetch_assoc($getRecords)) { $arr[] = array('id' => $getresult['id'], 'subjects' => $getresult['subject_name'], 'name' => $getresult['student_name']), } In student_subject table I have at least 5 subjects(different rows) pointing to the same student. But the variable subjects in the array can only get 1 value how I can get those other subjects . I need simple solution/query coz I just started learning about this. Thank you for your help Hi, first of all thanks in advance for the help. I'm a newbie college student and am having a little problem with a project for a class that I can't figure out. I'm trying to construct a loop that creates an array for a javascript image gallery. First I call for the categories and I want to then pull all the images from that category into the array and then loop through all the categories in the database. The code below just cycles through the first category and then quits after pulling the images from that category. Code: [Select] <?php // SQL Query for Categories $sql="SELECT CategoryID, CategoryName FROM pro2category"; $result = mysql_query($sql); if(empty($result)) { $num_results = 0; } else { $num_results = mysql_num_rows($result); } ?> <?php for($i=0; $i<$num_results; $i++) { $row = mysql_fetch_array($result); $CategoryID = $row["CategoryID"]; $CategoryName = $row["CategoryName"]; ?> var <?php echo $CategoryID ?> = new Array(); <!-- Images inside Array --> <!-- Images inside Array --> <!-- Images inside Array --> <!-- Images inside Array --> <?php $sql="SELECT ImageID, ImageName, ImageNumber, URL, CategoryID FROM pro2image WHERE CategoryID='$CategoryID'"; $result = mysql_query($sql); if(empty($result)) { $num_results = 0; } else { $num_results = mysql_num_rows($result); } ?> <?php for($i=0; $i<$num_results; $i++) { $row = mysql_fetch_array($result); $ImageID = $row["ImageID"]; ?> <?php echo $CategoryID ?>Array[<?php echo $i ?>] = "http://cgtweb2.tech.purdue.edu/356/zrodimel/Project2/admin/upload/<?php echo $ImageID ?>.jpg"; <?php } ?> <?php } ?> thanks for the help Zach Hello there, I am making a function to execute every time with a new demand no. in the while loop below. Every thing goes fine for the first time when the page loads, all the taxes come perfectly and each record is being read with the function calculateTaxes($demandno). But, when I press the search button with blank entries... All the entries come with only the first record. Means, the calculateTaxes function is not being loaded again and again with the loop when the press the search button. Please help. Please have a look in the below given code: Code: [Select] <?php function renderform($wardno, $demandno, $name) { include_once $_SERVER['DOCUMENT_ROOT'].'/npms/header.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/npms/config/config.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/npms/functions/functions.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/npms/functions/connect-db.php'; extract($GLOBALS); if ($demandno == '' && $wardno == '' && $name == '') // all empty. { $result = mysql_query("SELECT * FROM sform where paid=false order by wardno, id, demandno limit 0,$maxrecords") or die(mysql_error()); } if ($demandno != '' && $wardno != '' && $name != '') // all full. { $result = mysql_query("SELECT * FROM sform where demandno='$demandno' and wardno='$wardno' and (name like '%$name%') and paid=false order by wardno, id, demandno") or die(mysql_error()); } if ($demandno != '' && $wardno == '' && $name == '') // demand full else empty. { $result = mysql_query("SELECT * FROM sform where demandno='$demandno' and paid=false order by wardno, id, demandno") or die(mysql_error()); } if ($demandno != '' && $wardno != '' && $name == '') // demand and ward full else empty. { $result = mysql_query("SELECT * FROM sform where demandno='$demandno' and wardno='$wardno' and paid=false order by wardno, id, demandno") or die(mysql_error()); } if ($demandno == '' && $wardno != '' && $name == '') // ward full else empty. { $result = mysql_query("SELECT * FROM sform where wardno='$wardno' and paid=false order by wardno, id, demandno") or die(mysql_error()); } if ($demandno == '' && $wardno != '' && $name != '') // ward and name full else empty. { $result = mysql_query("SELECT * FROM sform where wardno='$wardno' and (name like '%$name%') and paid=false order by wardno, id, demandno") or die(mysql_error()); } if ($demandno == '' && $wardno == '' && $name != '') // name full else empty. { $result = mysql_query("SELECT * FROM sform where (name like '%$name%') and paid=false order by wardno, id, demandno") or die(mysql_error()); } if ($demandno != '' && $wardno == '' && $name != '') // demand and name full else empty. { $result = mysql_query("SELECT * FROM sform where demandno='$demandno' and (name like '%$name%') and paid=false order by wardno, id, demandno") or die(mysql_error()); } usleep(200000); // wait for 2 seconds ?> <link rel=stylesheet HREF="/npms/css/sp.css" type="text/css" media="screen"> <div id="content"> <div id="labelopt"></div> <h2>okMZokj ukxfjdksa dh lwph</h2> <div id="list"> <form name="spsearchform" action="" method="post"> <table border="1" cellpadding="2px"> <tr> <td id="labelmust" width="10%">fM- dz- %</td> <td><input class="english" type="text" size="15%" name="demandno" maxlength="40" value="<?php echo $demandno; ?>" /></td> <td id="labelmust" width="10%">okMZ dz- %</td> <td><input class="english" size="20%" type="text" size="15%" name="wardno" maxlength="3" value="<?php echo $wardno; ?>"/></td> <td id="labelmust" width="10%">uke %</td> <td><input class="hindi" size="30%" type="text" name="name" maxlength="100" value="<?php echo $name; ?>"/></td> <td><input type="submit" value="Search" name="btnsearch" /></td> </tr> </table> </form> <div style="color: red;"><small><cite>List is limited to <? echo $maxrecords; ?> records. For precise searching, use the search options above.</small></cite></div> <table border="1" cellpadding="2px"> <tr> <td colspan="8" id="english"><div style="float: right; color: red; text-align: right; margin-right: 10px;"><small><cite><strong><? echo mysql_num_rows($result); ?> records</strong> dumped.</cite></small></div></td> </tr> <tr> <td id="labelcenter">okMZ dz-</td> <td id="labelcenter">fMeka.M dzekad</td> <td id="labelcenter">uke</td> <td id="labelcenter">irk</td> <td id="labelcenter">'kq} dj</td> <td id="labelcenter">dj fooj.k</td> <td id="labelcenter">fu;kstu</td> <td id="labelcenter">feVk;sa</td> </tr> <?php if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array( $result )) { echo "<tr>"; echo "<td id='english'><center>" . $row['wardno'] . "</center></td>"; echo "<td id='english'><center>" . $row['demandno'] . "</center></td>"; echo "<td id='hindi'>" . $row['name'] . "</td>"; echo "<td id='hindi'>" . $row['address'] . "</td>"; $taxes = calculateTaxes($row['demandno']); echo "<td id='english' align='right'>" . number_format($taxes['grosstax'],2) . "</td>"; echo '<td><center><a href="payments/taxreport.php?demandno=' . $row['demandno'] . '"><img src="../images/payment.jpeg" width="15" height="15" /></center></a></td>'; echo '<td><center><a href="spedit.php?demandno=' . $row['demandno'] . '"><img src="../images/edit.gif" width="15" height="15" /></center></a></td>'; echo '<td><center><a href="spdelete.php?demandno=' . $row['demandno'] . '"><img src="../images/delete.jpeg" width="15" height="15" /></center></a></td>'; } } else { echo "<tr>"; echo "<td colspan='7' align='center'><blink><strong>lwph miyC/k ugha gS A</strong></blink></td>"; echo "</tr>"; } ?> </tr> </table> </div> <div id="menu"> <table> <tr> <td> <input type="button" value="New" name="btnnew" onclick="location.href='spnew.php';" /> <input type="button" value="Back" name="btnspback" onclick="location.href='../sp.php';" /> </td> </tr> </table> </div> </div> <?php include_once $_SERVER['DOCUMENT_ROOT'].'/npms/footer.php'; } include_once $_SERVER['DOCUMENT_ROOT'].'/npms/functions/connect-db.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/npms/functions/functions.php'; if(isset($_POST['btnsearch'])) { $wardno = mysql_real_escape_string(htmlspecialchars($_POST['wardno'])); $name = mysql_real_escape_string(htmlspecialchars($_POST['name'])); $demandno = mysql_real_escape_string(htmlspecialchars($_POST['demandno'])); renderform($demandno, $wardno, $name); } else { renderform('', '', ''); } ?> I am using file_get_contents to grab HTML pages. Seems to work fine as a part of a 1-shot function. But as soon as I include the function as part of a loop, it doesn't return anything... for ($i = 0; $i < 10; $i++) { ... getFile($urlArray[$i]; ... } function getFile($whatURL) { return strtolower(file_get_contents( $whatURL )); } I originally had the strtolower(file_get_contents( $whatURL )); line in the for loop but thought there needed to be some sort of pause for the file_get_contents method to function, but neither seems to work. What's the deal? |