PHP - Loop Constructing The Urls And Use Php To Fetch Up To Thousand Pages
i am new to PHP - and i want to learn some thing bout PHP - currently i have a little project - in order to get the links visited that this site presents http://www.educa.ch/dyn/79363.asp?action=search [search with wildcard % ] i parse with a loop. <?php $data = file_get_contents('http://www.educa.ch/dyn/79363.asp?action=search'); $regex = '/Page 1 of (.+?) results/'; preg_match($regex,$data,$match); var_dump($match); echo $match[1]; ?> in order to get the following pages http://www.educa.ch/dyn/79376.asp?id=4438 http://www.educa.ch/dyn/79376.asp?id=2939 If we are looping over a set of values, then we need to supply it as an array. I would guess something like this. As i am not sure which numbers which are filled with content - i therefore have to loop from 1 to 10000. So i make sure that i get all data. What do you think!? for ($i = 1; $i <= 10000; $i++) { // body of loop } according the following description: http://www.php.net/manual/en/control-structures.for.php Similar Tutorialsgood day dear community, i am workin on a Curl loop to fetch multiple pages: i have some examples - and a question: Example: If we want to get information from 3 sites with CURL we can do it like so: $list[1] = "http://www.example1.com"; $list[2] = "ftp://example.com"; $list[3] = "http://www.example2.com"; After creating the list of links we should initialize the cURL multi handle and adding the cURL handles. $curlHandle = curl_multi_init(); for ($i = 1;$i <= 3; $i++) $curl[$i] = addHandle($curlHandle,$list[$i]); Now we should execute the cURL multi handle retrive the content from the sub handles that we added to the cURL multi handle. ExecHandle($curlHandle); for ($i = 1;$i <= 3; $i++) { $text[$i] = curl_multi_getcontent ($curl[$i]); echo $text[$i]; } In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle! If we want to another Fetch of sites with cURL-Multi - since this is the most pretty way to do it! Well I am not sure bout the string concatenation. How to do it - Note I want to fetch several hundred pages: see the some details for this target-server sites - /(I have to create a loop over several hundred sites). * siteone.example/?show_subsite=9009 * siteone.example/?show_subsite=9742 * siteone.example/?show_subsite=9871 .... and so on and so forth Question: How to appy this loop into the array of the curl-multi? <?php /************************************\ * Multi interface in PHP with curl * * Requires PHP 5.0, Apache 2.0 and * * Curl * ************************************* * Writen By Cyborg 19671897 * * Bugfixed by Jeremy Ellman * \***********************************/ $urls = array( "siteone", "sitetwo", "sitethree" ); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $conn[$i]=curl_init($url); curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { $res[$i]=curl_multi_getcontent($conn[$i]); curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> I look forward to your ideas. How do you have a script, after getting the page, search for and as the result, post *part* of every link that ends like... &v=ANYTHING">Link text</a> and as the result, posting just ANYTHING">Link text<BR> I'm messing with... <?php $page = $_GET['page']; $user = $_GET['user']; $doc = new DOMDocument; $doc->load('http://m.youtube.com/profile?gl=US&client=mv-google&hl=en&user=$user&view=videos&p=$page'); $items = $doc->getElementsByTagName('a'); foreach($items as $value) { echo $value->nodeValue . "\n"; $attrs = $value->attributes; echo $attrs->getNamedItem('href')->nodeValue . "\n"; }; ?> but it get's way too much stuff. Get's data from every link on the page, and posts it as Page Text /watch?gl=US&client=mv-google&hl=en&v=XXXXX And I can't get $page = $_GET['page']; $user = $_GET['user']; to get the data from the URL. Hello, i have a query that returns multiple results but in my php query it only returns the first result...ive been checking google on while loops but still havent gotten it to work...would love if someone could look at it...thanks Code: [Select] // while ($result= mysql_fetch_array($stmt)){ while ($stmt->fetch()) { break; // $stmt->close(); // Return unlock code, encoded with JSON $result[] = array( "l_name"=>$l_name, "f_name"=>$f_name, "birth"=>$birth, "expires"=>$expires, ); sendResponse(200, json_encode($result)); return true; sendResponse(400, 'Invalid request'); return false Hi,
In my code i am fetching row per row out of my database through
->fetch(PDO::FETCH_ASSOC)this fetch have i put in a WHILE loop to fetch all the rows, one at a time while($select_rma_row = $select_rma_detail->fetch(PDO::FETCH_ASSOC)){In my array $select_rma_row there are a lot of value's that are (int) 1 and i really want to echo them as "YES" (1 = YES) What is the best way to change every (int) 1 to "YES" in that array? also is there a whay i can call every $key inside that array? Like you do with a foreach i.e. : if $select_rma_row[$key] == 1 { $select_rma_row[$key] == "YES"; }Thank you! Edited by Raz3rt, 21 May 2014 - 09:30 AM. Hey guys tried to search for this but didn't find anything usefull about the issue. So what i have is mssql_fetch_array in a while loop in the loop i have it assign a specified row as a variable that i can print later on in the page. Code: [Select] while($row = mssql_fetch_array($query) { $tables = "<tr>"; $tables .= "<td> {$row['specifiedrow']} </td>"; $tables .= "</tr>"; }Then i call it in the html table as Code: [Select] <? php echo $tables; ?> I have done this with mysql_fetch_array before and it would print the entire database row associated with that row in the table. But as it is now it only returns the last row from the database. Is there something i am missing. Thanks for any help Hi,
Does anyone have a clue how I might solve this little issue:
I have a MySQL query, for example:
<?php // Make a MySQL Connection $query = "SELECT * FROM staff"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ if($row['clock'] < time()) { echo "<b>"$row['name']. " - ". $row['age']"</b>"; echo "<br />"; } else { echo $row['name']. " - ". $row['age']; echo "<br />"; } } ?>Taking data from the following table setup: name - age - clock Timmy Mellowman - 23 - 09:00:00 Sandy Smith - 21 - 12:00:00 Bobby Wallace - 15 - 14:00:00 What im trying to achieve is compare the current time to the time in the clock column and depending if it's earlier or later, change the styling of the results. The above code does appear to work somewhat however it seems to change the styling of all results in one go, rather than individually when it passes the time in the cell, which is what im looking for. Thanks This is really blowing my mind... the code is as follows the table, the column names everything is right and contains information but the variables aren't being filled... I don't get it... Anyone have any ideas or options I might not have thought of for debugging? $item_name = ("SELECT * FROM items WHERE id = '$grab_item'"); $que_items = mysql_query($item_name); while ($item_todel = mysql_fetch_array($que_items, MYSQL_BOTH)) { $name = $item_todel['name']; $desc = $item_todel['desc']; } echo ($name . "<br>" . $desc . "<br>" . $grab_item); the only variable thats set is grab_item, fetch_array throws no errors, if I plug in the query straight to the sql I get all the proper information... It's just not filling the two variables.... Good Evening Php Programmers, I am trying to build a pagination script with mysqli using procedural style programming. Am a beginner. Not into oop yet or pdo. Bear that in mind if you show code samples. Else, i won't understand your snippets.
Anyway, here's how my script works ... $query_2 = "SELECT * FROM users WHERE first_name = ? AND marital_status = ? LIMIT $offset,$last_row_on_page";
When you click any page numbers on the pagination section, like page 2, then the fetch_rows() is supposed to fetch the relevant rows again for page 2. Note, rows_count() doesn't play here as I deem not necessary to re-count all matched rows. $query_2 = "SELECT * FROM users WHERE first_name = ? AND marital_status = ? LIMIT $offset,$last_row_on_page"; It displays the matching rows using this WHILE loop: while($row = mysqli_fetch_array($result_2,MYSQLI_ASSOC)) BIG ISSUE:
The fetch_rows() or $query_2 fails to fetch any matching rows beyond page 1 no matter what page you click. Be it page 2, 3, 4, etc.
Code is set to display 1 row per page for testing purpose. You can easily see which lines I am having trouble with if you notice the CAPITALISED comments in my code. //Do following if "Search" button clicked. if($_SERVER['REQUEST_METHOD'] === 'POST') {echo __LINE__; echo "<br>";//DELETE //Do following if "Search" button clicked. if(isset($_POST['search'])) {echo __LINE__; echo "<br>";//DELETE rows_count(); //This function will forward script flow to fetch_rows() before halting the script. die(); } } echo __LINE__; echo "<br>";//On PAGINATION PAGE 2, THIS FAILS TO ECHO. IT IS LINE: 24. //Do following if "Search" button not clicked but pagination numbered links are clicked. Eg Page 1, 2, 3, etc.. fetch_rows(); //On PAGINATION PAGE 2, THIS FUNCTION IS NOT GETTING TRIGGERED! WHY ? echo __LINE__; echo "<br>";//On PAGINATION PAGE 2, THIS GETS ECHOED. IT IS LINE: 205.
If you really want to help then best fire-up your Xampp/Wampp and feed my code and test it. DEVMODE CONTEXT: <?php error_reporting(E_ALL); ?> <!DOCTYPE HTML"> <html> <head> <meta name="viewport" content="width-device=width, initial-scale=1"> </head> <body> <?php session_start(); if(!isset($_GET['query_type']) && empty($_GET['query_type'])) { die("Invalid Query!"); } else { $_SESSION['query_type'] = $_GET['query_type']; echo __LINE__; echo "<br>";//DELETE } echo __LINE__; echo "<br>";//DELETE if(!isset($_GET['form_type']) && empty($_GET['form_type'])) { die("Invalid Form!"); } else { $_SESSION['form_type'] = $_GET['form_type']; echo __LINE__; echo "<br>";//DELETE if(!function_exists($_SESSION['form_type'])) { die("Invalid Form!"); } else {echo __LINE__; echo "<br>";//DELETE if(!session_id() || !isset($_SESSION['form_step']) || $_SESSION['form_step'] != 'end') { $_SESSION['form_step'] = 'start'; echo __LINE__; echo "<br>";//DELETE $_SESSION['form_type'](); } } } //FUNCTIONS START FROM HERE function search() {echo __LINE__; echo "<br>";//DELETE function rows_count() { //Connect to Database. (DB_SERVER, BD_USERNAME, DB_PASSWORD, DB_NAME). $conn = mysqli_connect("localhost","root","","powerpage"); $conn->set_charset('utf8mb4'); //Always set Charset. if($conn === false) { die("ERROR: Connection Error!. " . mysqli_connect_error()); } $query_1 = "SELECT COUNT(id) FROM users WHERE first_name = ? AND marital_status = ?"; $stmt_1 = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt_1,$query_1)) { mysqli_stmt_bind_param($stmt_1,"ss",$_POST["first_name"],$_POST["marital_status"]); mysqli_stmt_execute($stmt_1); $result_1 = mysqli_stmt_bind_result($stmt_1,$row_count); mysqli_stmt_fetch($stmt_1); $_SESSION['row_count'] = $row_count; echo __LINE__; echo "<br>";//DELETE $_SESSION['form_step'] = 'end'; fetch_rows(); } } function fetch_rows() { echo __LINE__; echo "<br>";//DELETE $form_step = $_GET['form_step']; $page_number = $_GET['page']; $result_per_page = $_GET['page_limit']; $offset = (($page_number * $result_per_page) - $result_per_page); //Offset (Row Number that 'Starts' on page). $last_row_on_page = ($page_number * $result_per_page); //Max Result (Row Number that 'Ends' on page). $previous_page = $page_number-1; $next_page = $page_number+1; echo "Row Start: $offset";echo "<br>"; echo "Row End: $last_row_on_page";echo "<br>"; //Connect to Database. (DB_SERVER, BD_USERNAME, DB_PASSWORD, DB_NAME). $conn = mysqli_connect("localhost","root","","powerpage"); $conn->set_charset('utf8mb4'); //Always set Charset. if($conn === false) { die("ERROR: Connection Error!. " . mysqli_connect_error()); } $query_2 = "SELECT * FROM users WHERE first_name = ? AND marital_status = ? LIMIT $offset,$last_row_on_page"; $stmt_2 = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt_2,$query_2)) {echo __LINE__; echo "<br>";//On PAGINATION PAGE 2, THIS GETS ECHOED. IT IS LINE: 103. mysqli_stmt_bind_param($stmt_2,"ss",$_POST["first_name"],$_POST["marital_status"]); mysqli_stmt_execute($stmt_2); $result_2 = mysqli_stmt_get_result($stmt_2); if(!$result_2) { //Close Connection. mysqli_close($conn); die("<pre>2c. Statement Fetching failed!</pre>"); } else {echo __LINE__; echo "<br>";//On PAGINATION PAGE 2, THIS GETS ECHOED. IT IS LINE: 114. //Grab total number of pages to paginate. $row_count = $_SESSION['row_count']; //$total_pages = ceil($result_1/$result_per_page); $total_pages = ceil($row_count/$result_per_page); echo "TOTAL PAGES: $total_pages<br><br>"; while($row = mysqli_fetch_array($result_2,MYSQLI_ASSOC))//On PAGE 2, PHP IGNORING THIS AND BYPASSING THIS WHOLE WHILE LOOP ON PAGE 2. IT IS LINE: 122. {echo __LINE__; echo "<br>";//On PAGE 2, THIS FAILS TO ECHO. IT IS LINE: 123. PHP IGNORING IT BYPASSING IT ON PAGE 2. //Retrieve Values. $id = $row["id"]; $first_name = $row["first_name"]; $middle_name = $row["middle_name"]; $surname = $row["surname"]; $gender = $row["gender"]; $marital_status = $row["marital_status"]; $working_status = $row["working_status"]; echo "Id: $id<br>"; echo "First Name: $first_name<br>"; echo "Middle Name: $middle_name<br>"; echo "Surname: $surname<br>"; echo "Gender: $gender<br>"; echo "Marital Status: $marital_status<br>"; echo "Working Status: $working_status<br>"; echo "<br>"; echo "<br>"; $i = 1; while($i<=$total_pages) { if($i<$total_pages) { echo "<a href='http://localhost/power.page/pagination_test_simple_WORKING_ON_NOW.php?form_type=";?><?php echo $_SESSION['form_type'];?>&query_type=<?php echo $_SESSION['query_type'];?>&form_step=end&page_limit=1&page=<?php echo $i;?>'><?php echo " $i ";?></a><?php } elseif($i==$page_number) { echo "<a href='http://localhost/power.page/pagination_test_simple_WORKING_ON_NOW.php?form_type=";?><?php echo $_SESSION['form_type'];?>&query_type=<?php echo $_SESSION['query_type'];?>&form_step=end&page_limit=1&page=<?php echo $i;?>'><?php echo "<b> $i </b>";?></a><?php } $i++; } if($page_number>$total_pages) { echo "<a href='http://localhost/power.page/pagination_test_simple_WORKING_ON_NOW.php?form_type=";?><?php echo $_SESSION['form_type'];?>&query_type=<?php echo $_SESSION['query_type'];?>&form_step=end&page_limit=1&page=<?php echo $previous_page;?>'><?php echo "<b> Previous </b>";?></a><?php } } } } $_SESSION['form_step'] = 'end'; } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>?form_type=<?php echo $_SESSION['form_type'];?>&query_type=<?php echo $_SESSION['query_type'];?>&form_step=end&page_limit=1&page=1" method='post' enctype='plain/text'> <?php //Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one. echo "<label for=\"first_name\">First Name *:</label> <input type=\"text\" name=\"first_name\" placeholder=\"First Name\" value = \"\">";?> <br> <?php echo "<label for=\"marital_status\">Marital Status *:</label>"; echo "<select name=\"marital_status\">"; echo "<option value=\"single\">Single</option>"; echo "<option value=\"married\">Married</option>"; echo "</select>"; echo "<br>"; ?> <input type="submit" name="search" value="Search"> <?php //$current_function = __FUNCTION__; //echo $current_function; //Do following if "Search" button clicked. if($_SERVER['REQUEST_METHOD'] === 'POST') {echo __LINE__; echo "<br>";//DELETE //Do following if "Search" button clicked. if(isset($_POST['search'])) {echo __LINE__; echo "<br>";//DELETE rows_count(); //This function will forward script flow to fetch_rows() before halting the script. die(); } } echo __LINE__; echo "<br>";//On PAGINATION PAGE 2, THIS FAILS TO ECHO. IT IS LINE: 24. //Do following if "Search" button not clicked but pagination numbered links are clicked. Eg Page 1, 2, 3, etc.. fetch_rows(); //On PAGINATION PAGE 2, THIS FUNCTION IS NOT GETTING TRIGGERED! WHY ? echo __LINE__; echo "<br>";//On PAGINATION PAGE 2, THIS GETS ECHOED. IT IS LINE: 205. } ?> What is wrong ? Why is fetch_rows() or $query_2 failing to fetch the matching rows for pages beyond page 1 ?
ECHOES 22 24 32 39 42 50 After clicking the SUBMIT button I get these echoed as expected: 193 71 78 Row Start: 0 Row End: 1 103 114 TOTAL PAGES: 5 123 After clicking the link for 'page 2' on pagination section, I get echoed the same line numbers I get echoed before clicking the SUBMIT button as if everything is starting all over with a new query (when not). That is not supposed to happen. I reckon line 200 is not taking action: fetch_rows(); //On PAGINATION PAGE 2, THIS FUNCTION IS NOT GETTING TRIGGERED! WHY ? IT IS LINE: 200. MAIN ISSUE HERE, I SUSPECT.
Hi all, I am looking a developing a script that instead of using something like mysite.com/showproduct.php?id=1 I would like it to appear as mysite.com/php-editor Is their a simple way of doing this? I would still need to pull info from a database so the page would still need to be dynamic, I just want it to appear static! I am used to using the get id function of php, what would the workaround be? would the id be hidden from the url but still usable in a query? I have had a look at the apache mod_rewrite, but quite frankly, I dont understand it! Cheers I am trying to work out how to correctly format an SQL query string from user data taken from multiple HTML text boxes/dropdowns. As an example assuming i have a searach page on which the user can enter search criteria into the following fields: name - text box site_location - drop down box (default set to 'search all') job_title - drop down box (default set to 'search all') manager - drop down box (default set to 'search all') email - textbox Its easy when all fields have user data set or one has user data set but when the user has entered data into only a couple of the fields I have problems constructing the SQL query, namely when it comes to adding the 'AND' keyword into the SQL query. No matter how i try to set out the logic in the PHP code i seem to end up with at least one combination of the search critea leading to back to back AND statements. I construct the SQL query by appending a string variable $query with the relevant search criteria, for example: $query = "select * from employees where "; if ($_POST['name'] != null) { $query=$query."name='".$_POST['name']."' "; } if ($_POST['site_location'] != 'all') { $query=$query."AND site_location='".$_POST['site_loaction']."' "; } //etc This does not work out though when fields are empty, I have tried adding additional if statements to check ahead to see if fields further down in the query are required and if so append an 'and' but I cannot seem to get the logic correct. Is this something anyone else has come accross, if so is there a better solution than the route i am going down? Thanks for reading. Hey.
So the issue I'm having is consecutive loops on semi-large arrays, over and over. Consider this array:
$firstArray = array( 'row1' => array( 'dates' => array( '2014-01-01' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-02' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-03' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-04' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-05' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-06' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-01-07' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), ) ), 'row2' => array( 'dates' => array( '2014-02-01' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-02' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-03' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-04' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-05' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-06' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-07' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-08' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), '2014-02-09' => array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4', 'key5' => 'value5', 'key6' => 'value6', 'key7' => 'value7', 'key8' => 'value8', 'key9' => 'value9', 'key10' => 'value10'), ) ) );Originally the data comes from ~2-3 database tables, of course. But to ilustrate the point, this is how the main array looks like. This array usually contains anywhere between 10-50 rows, each row containing at least 10 dates, with 10 key/values each. And after setting up all the data, it needs to be processed. Currently this is how a friend of mine did it.. $placeDataHere = array(); foreach($firstArray as $key => $dates) { foreach($dates as $date => $values) { foreach($values as $key => $value) { $placeDataHere['DV_' . $date]['SM_' . $key] = 'KS_' . $value; //Followed by another ~50-70 lines of processing the 3 loop's data.. ... ... .... .... .... .... .... .... } } }Obviously this isn't good practise, but we can't seem to figure out a better way of doing it, since both the data and the loops are horribly nested. This loop and setup of $firstArray is run anywhere between 10-20 times/request, due to amount of users we wish to process. So, the result is that this code can take up to over 2-3 minutes to complete, which isn't really optimal performance. In short my question is, are there any better methods of handling this with the data setup we currently have? Is their something I can do in PHP (like some sort of function/config/array etc...) which would make the following process easier (examples appreciated)... I have an .htaccess file where im rewriting urls to seo friendly ones...now in the PHP script is their something I can place for urls are meant to be displayed/linked (like some sort of placeholder) which makes it easier for me to modify the urls within the PHP script, without constantly editing countless php sourcecode to just change the url? Example scenario: Say I had a php file (called submit.php): <?php echo 'Hey! Thanks for submiting the form, <a href="submit.php?form">click here</a> to go back!'; ?> and my rewrite rule for submit.php?form was: /form How would I easily change the url within submit.php without editing submit.php directly? Hello, Ive got many URLs like these which im trying to just get the name for example "Ace Lightning" Quote http://www.wupload.com/file/1374721/Ace Lightning # GBA.rar http://www.wupload.com/file/1374722/Action Man - Robotatak # GBA.rar http://www.wupload.com/file/1374726/Activision Anthology # GBA.rar http://www.wupload.com/file/1374761/Advance Guardian Heroes # GBA.rar http://www.wupload.com/file/1374764/Agassi Tennis Generation # GBA.rar This is my code Code: [Select] <?php if($_POST['newlinks']) { $newlinks = $_POST["newlinks"]; $newlinks = preg_split("/.rar/", $newlinks); foreach ($newlinks as $newlink) { $r_name = substr("$newlink", 36, 100); echo "<strong>Game Name: $r_name</strong> <br />"; } } echo "<form method=\"POST\" action=\"index.php?page=mass-gba\">"; echo "<br /> <strong>Mass Add GBA ROMs</strong> <br />"; echo "<textarea rows=\"16\" name=\"newlinks\" cols=\"84\"></textarea>"; echo "<input type=\"submit\" value=\"Mass Add GBA Links\" name=\"B1\">"; echo "</form>"; ?> This results are like this, I cant understand why it works for the first game but not the second or any after that. Quote True Name: Ace Lightning # GBA True Name: 2/Action Man - Robotatak # GBA True Name: 6/Activision Anthology # GBA True Name: 1/Advance Guardian Heroes # GBA True Name: 4/Agassi Tennis Generation # GBA Hello! First... I'm sorry about my english skills.. Seems that with my own language I don't get a correct or good answer So.. I have a site where visitors can put there favorite links to other sites and show them to others. My problem is multiple urls to same locations in sites-table. example: http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php (?) they all lead to same... is there any light and powerfull way to check these? I'm trying to use query with "like" but it only works if there is exactly same url. I use fopen to check that url really exicst.. table: Sites (basic information for link) -id -url -title +some meta tags if found -timestamp I'm not asking to do me this code. But if someone can tell me just what functions and others I'm looking for and what I need for this... My coal is to keep sites-table as clean as it can be. If visitor adds a url that is already in sites-table only thing that happens is updating timestamp. Thank you all for helping me! -Roosterr Say my URL is http://www.example.com/catalog.php?category=hats&prodID=53 and I use Mod-rewrite to make it http://www.example.com/catalog/hats/53/ Can I still use $_GET['category'] to get the parameters? If so, how? Hi, What is the best way to change: www.mysite.com/product.php?id=1&sort=2&cat=z to: www.mysite.com/1/product-name-here I would need the other variables in the URL (sort & cat...) to also pass through to the new address. Is this an .htaccess change or via PHP code? Any help appreciated, thanks. I would love to google my question, but I don't know how this is called.... I want to create URLs for each user of a site with this format: www.mysite.com/user1 Facebook does this, for example. In a static page I'd do it with a folder and index file for each user, but that's not practical if you have too many users. Could you explain how this is done or at least how it is called so I can find myself something to read? Thanks!!! Hi All, Currently, in my application, my links use index.php?id=14 (or whatever ID it is). Should I somehow encrypt those so the exact ID is not known or is this OK? Can someone help me to generate SEO friendly URLs? I dont want my URLs to be presented like: www.example.com/listprod.php?categ=1&subcateg=7 I want it to dynamically do the following: www.example.com/listprod/cameras/slr |