[PHP-DB] Re: Array Display
The display will look like 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 Everybody on level 1 will be on same row and so on On 5/7/08, A. Joseph [EMAIL PROTECTED] wrote: Please i knew this not the best place to post this message but i ain`t gat no option i need fast help on this I have a Array and data are grouped according to level, so want to display everybody on same level in same HTML row os if you are on level 0 then you first, to the next people on level one, then level 1 on samle row so on.. Array sample is Array ( [0] = Array ( [0] = 1009603 [section_id] = 1009603 [1] = 4 [section_left] = 4 [2] = 11 [section_right] = 11 [3] = 1 [section_level] = 1 [4] = Joseph Abah [section_name] = Joseph Abah ) [1] = Array ( [0] = 1009956 [section_id] = 1009956 [1] = 5 [section_left] = 5 [2] = 8 [section_right] = 8 [3] = 2 [section_level] = 2 [4] = Onuche Mikel [section_name] = Onuche Mikel ) [2] = Array ( [0] = 1005539 [section_id] = 1005539 [1] = 9 [section_left] = 9 [2] = 10 [section_right] = 10 [3] = 2 [section_level] = 2 [4] = Owen Joncena [section_name] = Owen Joncena ) ) Thank you. On 5/6/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am opening a rss file using fopen. If I use direct value, it can be opened, but I use a paremeter, I obtain an error. This works: ... xml_set_character_data_handler($xml_parser, characterData); $fp = fopen(http://www.arteglobal.net/news.xml,r;) or die(Error reading RSS data.); while ($data = fread($fp, 4096)) { xml_parse($xml_parser, $data, feof($fp)) ... But this one not (Error reading RSS data): ... $url_rss = http://www.arteglobal.net/news.xml;; ... xml_set_character_data_handler($xml_parser, characterData); $fp = fopen($url_rss,r) or die(Error reading RSS data.); while ($data = fread($fp, 4096)) { xml_parse($xml_parser, $data, feof($fp)) ... Any idea about what is happening?. Thank you! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- I develop dynamic website with PHP MySql, Let me know about your site -- I develop dynamic website with PHP MySql, Let me know about your site -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: array messing up
Rainer Bendig Aka Ny wrote: I want to build an array containing two arrays $navm[] and $navs[], $navs[] should go to $navm[items]. - -sourcecode:start8-- $resultm = $db-query(SELECT * FROM .$p._cats WHERE ms='m' \ ORDER BY sortorder ASC); while($work_res_navm = $db-fetch_array($resultm)) { $results = $db-query(SELECT * FROM .$p._cats \ WHERE master='.$work_res_navm['catid'].' \ ORDER BY sortorder ASC); $navs = array(); while($work_res_navs = $db-fetch_array($results)) { $navs[]=array('link'=$work_res_navs['link'], \ 'text'= $work_res_navs['name'], \ 'id'= $work_res_navs['catid'], \ 'master'=$work_res_navs['master'] ); } $navm[] =array('link'=$work_res_navm['link'], \ 'text'= $work_res_navm['name'], \ 'id'= $work_res_navm['catid'], \ 'items'=$navs); }; - -sourcecode:stop-8-- the array now looks like this: $navm1-0 $navs1-1 $navs1-2 $navm2-0 $navs1-1 $navs1-2 $navs2-1 $navm3-0 $navs1-1 $navs1-2 $navs2-1 $navs3-1 and the same procedure a lot more often... but it should look like this: $navm1-0 $navs1-1 $navs1-2 $navm2-0 $navs2-1 $navm3-0 $navs3-1 and so on what is my error? you forget to empty the array $navs! -- Sebastian Mendel www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Array
Miguel Guirao [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi!! I have a table with many options from when the user can select them, after that, his/her selections will be stored in a database. In the mean time, I want to store his/her selections in an array like this one: PN Desc Qty |---|--|---| |---|--|---| |---|--|---| How do I declare Duch an array like this??, let's call it Parts. Miguel Guirao Servicios Datacard www.SIASA.com.mx Hi, do you mean this: $parts = array(array('PN' = $PN_value1, 'Desc' = $Desc_value1, 'Qty' = $Qty_value1), array('PN' = $PN_value2, 'Desc' = $Desc_value2, 'Qty' = $Qty_value2), array('PN' = $PN_value3, 'Desc' = $Desc_value3, 'Qty' = $Qty_value3) ); Regards, Torsten Roehr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: array
if($access ==2) { echo do something; } Peppe wrote: Hi I have a variable cold $access and there are values 1,2,3,4,5 How can I check for example If ($access =='2'){ echo go further; } How can I make this work Thanx in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: array
Hi Pete I forgot to write that $acces is a field from Db and there are values 1,2,3,4 a need to split those values to make that IF Brettking I think that is solution Peppe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi I have a variable cold $access and there are values 1,2,3,4,5 How can I check for example If ($access =='2'){ echo go further; } How can I make this work Thanx in advance -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Array loops
Hi there. here ya go. $array_of_exams = Array(); $array_of_exams['Full Head'] = 'Head Examination History'; $array_of_exams['Full Body'] = 'Body Examination History'; $array_of_exams['Full Butt'] = 'Butt Examination History'; $exam_dates = Array(); foreach ($array_of_exams as $exam = $description) { $neh=select * from pro_list, complete_pro where pro_list.pro_name ='$exam' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'; $resneh=safe_query($neh); $exam_count = 0; while ($rown=mysql_fetch_array($resneh)){ $exam_dates[$exam][$exam_count] = $rown['compl_date']; $exam_count++; } } foreach ($array_of_exams as $exam = $description) { foreach ($exam_dates[$exam] as $date_done) { echo p1. $description : $date_done; } } That should do all that u want It will list all exam times that meet your search. Joel Colombo Robin Sanchez [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am creating a results page for completed and uncompleted procedures. I am repeating a lot of the code and wonder if there is an easier way to do this. $neh=select * from pro_list, complete_pro where pro_list.pro_name ='Neurological Exam/History' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'; $resneh=safe_query($neh); while ($rown=mysql_fetch_array($resneh)){ $compl_date1=$rown['compl_date']; } echo p1. Neurological Exam and History $compl_date1; $neh=select * from pro_list, complete_pro where pro_list.pro_name ='Ankle Arm BP Measurement' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'; $resneh=safe_query($neh); while ($rown=mysql_fetch_array($resneh)){ $compl_date2=$rown['compl_date']; } echo P2. Ankle/Arm BP Measurement $compl_date2; and so on and so on... It seems that I could use a 'for' loop in the searches, but how do I populate the result fields (some of which will be empty) with the appropriate tests. Any thoughts. Ozzie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Array loops
Thanks that works like a charm and I learned some tricks that I can apply to some other code!!! Ozzie Hi there. here ya go. $array_of_exams = Array(); $array_of_exams['Full Head'] = 'Head Examination History'; $array_of_exams['Full Body'] = 'Body Examination History'; $array_of_exams['Full Butt'] = 'Butt Examination History'; $exam_dates = Array(); foreach ($array_of_exams as $exam = $description) { $neh=select * from pro_list, complete_pro where pro_list.pro_name ='$exam' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'; $resneh=safe_query($neh); $exam_count = 0; while ($rown=mysql_fetch_array($resneh)){ $exam_dates[$exam][$exam_count] = $rown['compl_date']; $exam_count++; } } foreach ($array_of_exams as $exam = $description) { foreach ($exam_dates[$exam] as $date_done) { echo p1. $description : $date_done; } } That should do all that u want It will list all exam times that meet your search. Joel Colombo Robin Sanchez [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am creating a results page for completed and uncompleted procedures. I am repeating a lot of the code and wonder if there is an easier way to do this. $neh=select * from pro_list, complete_pro where pro_list.pro_name ='Neurological Exam/History' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'; $resneh=safe_query($neh); while ($rown=mysql_fetch_array($resneh)){ $compl_date1=$rown['compl_date']; } echo p1. Neurological Exam and History $compl_date1; $neh=select * from pro_list, complete_pro where pro_list.pro_name ='Ankle Arm BP Measurement' and complete_pro.proid=pro_list.proid and complete_pro.sysid='$sysid' and complete_pro.transid='$transid'; $resneh=safe_query($neh); while ($rown=mysql_fetch_array($resneh)){ $compl_date2=$rown['compl_date']; } echo P2. Ankle/Arm BP Measurement $compl_date2; and so on and so on... It seems that I could use a 'for' loop in the searches, but how do I populate the result fields (some of which will be empty) with the appropriate tests. Any thoughts. Ozzie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Array printing
Much simpler: foreach ($arrText as $text) { print $text; } Use that code. Just add in your HTML tags and it will be much cleaner and faster. Michael Conway [EMAIL PROTECTED] wrote in message news:!~!UENERkVCMDkAAQACABgAeI4MkiQKXEijmrrs5/EPIcKA [EMAIL PROTECTED] I am using an array to return the contents of a file. The file root is located on the db and the file content is correctly rendered using the following code: echo \n\ttd ALIGN=LEFT bgcolor = \silver\ . $arrText= file($row[description]); for ($i=0; $icount($arrText); $i++) { echo(P ALIGN=LEFTPREb$arrText[$i]/b/PRE/P); } Everything works fine except that the paragraph is led off by the pesky Array tag, such as: Array File contents here.. Is there a way to suppress or hide the Array tag? I realize that there probably is an excruciatingly simple solution, but I have not found it yet. Thanks. Michael Conway [EMAIL PROTECTED] (703) 968-8875 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Array help needed :-(
You may want to revisit your db design, but if it is like that for reason then it is simple enough to associate these items with each other in an array. Just put together a query then get the row and split it by the commas then put it into an array as follows. $ar = Array('small' = '1.99', 'medium' = '2.99', 'large' = '3,99'); Then you can access these values by the following. $smvalue = $ar['small'] This example is a simple array, if you had a lot of products you could use a multi dimensional array like this. $ar = Array( 'hotdogs' = Array('small' = '1.99', 'medium' = '2.99', 'large' = '3,99'), 'burgers' = Array('small' = '2.99', 'medium' = '4.99', 'large' = '6,99')) Then access them like this $smallburger = $ar['burger']['small'] Hope this helps. Simon -Original Message- From: David Robley [mailto:[EMAIL PROTECTED]] Sent: 8 October 2002 06:49 To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Array help needed :-( In article 000801c26e10$a2128510$f7fea8c0@chris, [EMAIL PROTECTED] says... Hi there everyone, I have a problem i'm trying to figure out but i'm not too good with arrays, just know the basics, if anyone could help me out on this it would be wonderful :-) I have two sets of data in columns of a MySQL DB, these items are size and price. Size is seperate by comma's in the first column, and I have it split into a dropdown box no problem to read (For example): small medium large but then I have a price field, which contains 1.99,2.99,3.99 etc . what I need to do is when someone selects an item from the dropdown - say small as an example, it would know how to get 1.99 from the price entry in the DB. I guess what I need to do is somehow associate each entry in the price field with those in the size, but I have no idea how to do it :-( Any help would be really appreciated as this stumps the hell out of me. Thanks Chris I think you may have a problem with your database design? Can you explain a little more exactly what it is you are trying to do and perhaps someone can advise on how your data might best be structured. -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: array intersect with 2 arrays created from mysql
It may be because your not initialising your array. ie: $partner_type = array(); $partner_region = array(); PHP should automatically make it an array (if its not previously a different type) as soon as you do $partner_type[] but if you get no results from your query then it wont be an array. Cheers, Owen Prime http://www.noggin.com.au Nigel Dunn wrote: Hi, If anyone can help me with this I'd be most appreciative. I'm constructing 2 arrays of IDs from 2 different tables. Then I want to compare one to the other and only use the results that both arrays share in common to do a query loop that pulls the information for the related IDs to display. The error I get from the code below is: Warning: Argument #2 to array_intersect() is not an array in /usr/local/www/vhosts/trustbuild.co.nz/htdocs/partners_region.php on line 185 I cant see what is causing the problem. Start of My Existing Code $result = mysql_query(SELECT partner_id FROM partner_region WHERE region_id = '$r' ORDER BY partner_id); if ($row = mysql_fetch_array($result)) { do { partner_region[] = $row['partner_id']; } while ($row = mysql_fetch_array($result)); } if (count($partner_region) != 0) { array_unique($partner_region); } $result2 = mysql_query(SELECT id FROM partner WHERE type = '$t' ORDER BY id); if ($row2 = mysql_fetch_array($result2)) { do { partner_type[] = $row2['id']; } while ($row2 = mysql_fetch_array($result2)); } if (count($partner_type) != 0) { array_unique($partner_type); } $partner = array_intersect($partner_region, $partner_type); if (count($partner) != 0) { foreach ($partner as $p) { $result3 = mysql_query(SELECT * FROM partner WHERE id = '$p'); if ($row3 = mysql_fetch_array($result3)) { do { $company_name = $row3['company_name']; $contact_name = $row3['contact_name']; $physical_address = $row3['physical_address']; $postal_address = $row3['postal_address']; $city = $row3['city']; $phone = $row3['phone']; $fax = $row3['fax']; $email = $row3['email']; $url = $row3['url']; $gst_number = $row3['gst_number']; $company_age = $row3['company_age']; $services = $row3['services']; $region = region($r); if ($count == 0) { echo trtd bgcolor='#FF'a href='closeup.php?id=$id'$region $company_name/abrType: $company_typebrContact Name: $contact_namebr.nl2br($physical_address)./td/tr; $count++; } else { echo trtd bgcolor='#DD'a href='closeup.php?id=$id'$region $company_name/abrType: $company_typebrContact Name: $contact_namebr.nl2br($physical_address)./td/tr; $count--; } } while ($row3 = mysql_fetch_array($result3)); } } } else { echo There are no listings for your criteria. Please try again.br; } End of My Existing Code Thanks in advance for any help with this one, Nigel Dunn -- Cheers, Owen Prime http://www.noggin.com.au -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Array help needed :-(
In article 000801c26e10$a2128510$f7fea8c0@chris, [EMAIL PROTECTED] says... Hi there everyone, I have a problem i'm trying to figure out but i'm not too good with arrays, just know the basics, if anyone could help me out on this it would be wonderful :-) I have two sets of data in columns of a MySQL DB, these items are size and price. Size is seperate by comma's in the first column, and I have it split into a dropdown box no problem to read (For example): small medium large but then I have a price field, which contains 1.99,2.99,3.99 etc . what I need to do is when someone selects an item from the dropdown - say small as an example, it would know how to get 1.99 from the price entry in the DB. I guess what I need to do is somehow associate each entry in the price field with those in the size, but I have no idea how to do it :-( Any help would be really appreciated as this stumps the hell out of me. Thanks Chris I think you may have a problem with your database design? Can you explain a little more exactly what it is you are trying to do and perhaps someone can advise on how your data might best be structured. -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ARRAY, IF INSERT
(i am new to these groups, but shouldn't there be a follow-up-to on a X-post?) César aracena wrote: I have this form in which one Administrator can insert new members and after that, in another page, a form where he/she can insert the new members sons daughters. I want to display a table with text inserts into the admin can type lets say a maximum of 5 kids in the second page. The number doesn't matter if you design you db well (I suppose we are talking database). I suppose that you have a table with members with unique ID's? Make a new table with relatives, where you connect to their parents through a ParentID-field This way you'll avoid empty fields for the folks with eg. only 2 sons :-) The query for father + sons and daughters would then be like mysql_query( select members.Name, members.ID, relatives.Name as RelativeName, relatives.ID from parents, relatives where parents.ID = relatives.ParentID ) The members table will have one memberID field (which will be shared between parents and kids) and a levelID which will grant 0 for the parent and 1, 2, 3, 4, 5 for the kids. You _can_ put them all in the same table, but I suppose that you have a lot of data stored on the parents/members, that is non-existing and irellevant for the children - this will give a lot of empty fields, which is why i propose the solution above... Now, how do I tell PHP to make an array from the kids input, but only from the fields in which lets say the name field was filled out in order to spend the necessary tables rows. Another thing the Array should also specify new levelIDs for each kid from 1 to 5. It would be great if you also show me how to deal with it after its created. It's easy to select only rows with contents for at certain field: select * from relatives where Name 0 I hope this was of some help? regards Jesper Brunholm -- Phønix - Danish folkmusic from young musicians - http://www.phonixfolk.dk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Array not supported for strings???
-Original Message- From: Andy [mailto:[EMAIL PROTECTED]] Sent: 04 January 2002 20:24 To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Array not supported for strings??? $stmt= SELECT country from $DB2.$geo_T1 where country_code = '$country_id[$i]' ; Well, this should be where country_code = '${country_id[$i]}' to be sure of doing what you want. This code: $country[] = $row-country; Creates following error msg: Fatal error: [] operator not supported for strings Is this error coming from PHP or your database? And does it definitely refer to this particular line? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: Array not supported for strings???
On Saturday 05 January 2002 04:24, Andy wrote: Here is the full code: ### # Get the name of the country: if (isset($country_id)){ //only if there are results for($i=0; $i count($country_id); $i++){ $stmt= SELECT country from $DB2.$geo_T1 where country_code = '$country_id[$i]' ; if ( !($result = execute_stmt($stmt, $link) )){ HEADER(Location:empty); } while ($row = mysql_fetch_object($result)){ //$country[] = $row-country; }; }; }; ### Andy [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there, I have a problem with an array: This code: $country[] = $row-country; Creates following error msg: Fatal error: [] operator not supported for strings The wired thing is, that the same procedure works through my whole application, but not in this case. Did anybody make the same experience? You've probably used $country before in a string context. Just reset it to some known state before your while loop: unset($country); OR $country=; should do the trick. hth -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* I'd love to go out with you, but I'm converting my calendar watch from Julian to Gregorian. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Array and ID
Hi, I have a drop-down menu that has been prepopulated with an array from a column name CompanyName. What I need to do is take the CompanyName lookup the CompanyID in the company table and insert the CompanyID into a row in a table called contacts with a CompnayID column. [...] Is this a multiple or a single select? A quick and dirty thought: ?php $sql and $query as they were echo select name=\company\; while ($row = mysql_fetch_array($query)) { echo option value=\$row['CompanyID']\$row['CompanyName']/option; // I didn't get the if-else statement you had here before. I think it is better to have // the id as the value and not the name. } ? So if the from (which I assume you are using) is submitted you have $company with the CompanyID as its value which then can be inserted. If it is a multiple select you have to do it with an array but shouldn't be too tricky either hope it helps Johannes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]