
peterg0123
Members-
Posts
14 -
Joined
-
Last visited
Never
Contact Methods
-
Website URL
http://www.boomarang.co.za
Profile Information
-
Gender
Male
-
Location
South Africa
peterg0123's Achievements

Newbie (1/5)
0
Reputation
-
Hi, Have a question regarding array handling / changes. I have the below posted array. I need to consolidation the "categoryId" & "categoryName" where the "id" have the same value e.g. 66, then remove the duplicates but keep the merged data. The new merged data could be stored under a key e.g. [categories] => Array ( [0] [categoryId] = 28 [categoryName] = Game Drive [1] [categoryId] = 29 [categoryName] = Game Drive etc. Array ( [0] => Array ( [id] => 66 [name] => Person Name [description] => Test Desc [webUrl] => www.nish.co.za [emailAddress] => [email protected] [telNumber] => 123123 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-27 17:42:55 [activated] => Y [categoryId] => 28 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Game Drives ) [1] => Array ( [id] => 66 [name] => Person Name [description] => Test Desc [webUrl] => www.nish.co.za [emailAddress] => [email protected] [telNumber] => 123123 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-27 17:42:55 [activated] => Y [categoryId] => 29 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Nature Reserve ) [2] => Array ( [id] => 66 [name] => Person Name [description] => Test Desc [webUrl] => www.nish.co.za [emailAddress] => [email protected] [telNumber] => 123123 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-27 17:42:55 [activated] => Y [categoryId] => 34 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Rehabilitation Centre ) [3] => Array ( [id] => 65 [name] => Person Name [description] => This is the true test [webUrl] => http://www.klil.com [emailAddress] => [email protected] [telNumber] => 12311231 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-26 19:33:14 [activated] => Y [categoryId] => 28 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Game Drives ) [4] => Array ( [id] => 65 [name] => Test Multiple Categ [description] => This is the true test [webUrl] => http://www.klil.com [emailAddress] => [email protected] [telNumber] => 12311231 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-26 19:33:14 [activated] => Y [categoryId] => 29 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Nature Reserve ) [5] => Array ( [id] => 65 [name] => Person Name [description] => Description Text [webUrl] => http://www.test.com [emailAddress] => [email protected] [telNumber] => 12311231 [provinceId] => 3 [cityId] => 2 [creationDate] => 2010-09-26 19:33:14 [activated] => Y [categoryId] => 34 [provinceName] => Gauteng [cityName] => Johannesburg [categoryName] => Rehabilitation Centre ) [6] => Array ( [id] => 64 [name] => Person Name [description] => Description Text [webUrl] => www.tree.com [emailAddress] => [email protected] [telNumber] => 1123123123 [provinceId] => 3 [cityId] => 1 [creationDate] => 2010-09-26 12:10:56 [activated] => Y [categoryId] => 28 [provinceName] => Gauteng [cityName] => Alexandra [categoryName] => Nature Walks ) [7] => Array ( [id] => 64 [name] => Person Name [description] => Description Text [webUrl] => www.tree.com [emailAddress] => [email protected] [telNumber] => 1123123123 [provinceId] => 3 [cityId] => 1 [creationDate] => 2010-09-26 12:10:56 [activated] => Y [categoryId] => 29 [provinceName] => Gauteng [cityName] => Alexandra [categoryName] => Nature Reserve ) [8] => Array ( [id] => 64 [name] => Person Name [description] => Description Text [webUrl] => www.tree.com [emailAddress] => [email protected] [telNumber] => 1123123123 [provinceId] => 3 [cityId] => 1 [creationDate] => 2010-09-26 12:10:56 [activated] => Y [categoryId] => 34 [provinceName] => Gauteng [cityName] => Alexandra [categoryName] => Rehabilitation Centre ) [9] => Array ( [id] => 63 [name] => Person Name [description] => Description Text [webUrl] => www.test.com [emailAddress] => [email protected] [telNumber] => 123123 [provinceId] => 5 [cityId] => 3 [creationDate] => 2010-09-26 09:58:41 [activated] => Y [categoryId] => 29 [provinceName] => Limpopo [cityName] => Bandelierkop [categoryName] => Nature Reserve ) ) Thanks in advance, Peter
-
Hi, I am very new to mysql scripting and I am trying to write a query using joins. The problem is that I only returns 1 row everytime where the categoryId = 29. There are definetly other rows that should be returned? Any help would be great... SELECT tbl_posts.id, tbl_posts.name, tbl_posts.description,tbl_posts.webUrl, tbl_posts.emailAddress, tbl_posts.telNumber,tbl_posts.provinceId, tbl_posts.cityId,tbl_posts.creationDate, tbl_posts.activated,tbl_post_categories.categoryId,tbl_provinces.name as provinceName, tbl_cities.name as cityName, tbl_categories.name as categoryName FROM tbl_posts JOIN tbl_post_categories ON tbl_posts.Id = tbl_post_categories.postId JOIN tbl_categories ON tbl_post_categories.categoryId = tbl_categories.id JOIN tbl_provinces ON tbl_posts.provinceId = tbl_provinces.id JOIN tbl_cities ON tbl_posts.cityId = tbl_cities.id WHERE tbl_post_categories.categoryId ='29' Thanks in advance, Peter
-
Hi, This line of code will always stop here and go no further. Because when you call include("header1.php"); it checks the below. These global vars (user && pass) have not been set yet and "exit" will terminate the script. <?if (!session_is_registered("user") || !session_is_registered("pass")) { print "<center><font color=silver>Your session is over you will need to log back in....<a href=index.php>CLICK HERE</a>."; exit;} Also session_is_registered has been deprecated. Use isset() on the $_SESSION global var. e.g. !isset($_SESSION['user'])
-
Hi, What version of PHP is your new host running?
-
We need some code...
-
Insert data in Mysql and move to another page
peterg0123 replied to md7dani's topic in PHP Coding Help
Hi, For the below code. Make sure that there is no code before header("Location: nextpage.php") that outputs any text or errors. Also try putting the code above all html code on the page, basically the first lines on the page above the HEAD, TITLE, BODY DOCTYPE... Also are you sure your mail_send.php is not outputting a message or error. That would stop the header location from working potentially? if(isset($_POST['submit'])) { // PROCESS DATA POST TO DB e.g. execute function here... if(!mysql_error()) { header('Location: nextpage.php'); } } else { //do the funky chicken } -
I believe it will just update the column with current year as there are no other conditions. When you "if it is not already set", what would it be if not set? because you could check ..."WHERE username = '$username' AND Used < YEAR(CURDATE())".
-
Hi, Try removing the ";" before ".gif" echo "<body style='background-image: url( ".$_POST['user_color'].".gif)'</body>"; Cheers Peter
-
Hi, Just a quick question about sessions. Why do some people pass the session id in the URL? Thanks Peter
-
<?php function getTopCategories () { return getSubCategories(0); /* top-level categories are just sub categories without a parent id */ } function getSubCategories($parentId){ $sql = "SELECT category_id,parent_id,category_title FROM tbl_categories WHERE parent_id = $parentId"; $rs = mysql_query ($sql); $results = (array)NULL; while ($row = mysql_fetch_assoc($rs)) { $id = $row["category_id"]; $items = getItems($id); $subcategories = getSubCategories($id); $results[$row["category_title"]] = (array)NULL; foreach (array ($items, $subcategories) as $resultset) { foreach ($resultset as $result) { $results[$row["category_title"]][] = $result; } } } return $results; } function getItems ($category_id) { $sql = "SELECT category_id,category_title FROM tbl_categories WHERE category_id='$category_id'"; $rs = mysql_query ($sql); $results = (array)NULL; while ($row = mysql_fetch_assoc ($rs)) { $results[] = $row; } return $results; } ?>
-
Hi, Thanks for the link. Tried it but it get the following:- I think I need a recursive function or something? Peter
-
Hi, Not sure that will work. The array is built dynamically? Any other idea's. Thanks
-
Hi, How can I print this multidimensional array out? Below is a print_r of the array: It is basically for a dropdown menu of categories. Thanks in advance Peter
-
Hi, Can anyone tell me the process or steps (not code) to reading a mailbox and extracting the different sections / parts of a message. I know you start with imap_open(), but not certain where to go from hear? Thanks Peter Guest