Jump to content

genius_supreme

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by genius_supreme

  1. ChristianF point noted. guess will be using get method via hyperlink.
  2. all this are getting too complicated for me. query result=n number of records while loop for query result fetch array $qry print button name="btn".$btn $btn++; end while loop assuming form has btn1 to btnN how do I identify which button was clicked? another way I can think off is using GET method via hyperlink for each row. I have done this before but thought of using a button would be easier.
  3. I use while loop to create the buttons as well as fetch array of records. how do I use another loop to process n number of buttons where n=unknown
  4. Barand I appreciate your help again but that's not what I'm looking for. I wouldn't know now many case to put in when I don't know how many record will result in the query. the form will also be generated dynamically based on number of record
  5. I'm trying to have a multiple submit button (or if there is any other way) to update each row of record individually. What i want is to identify which button was clicked. The records are displayed in a table format from 3 different tables in the same database. Each row of the query printed with a submit button. Previously i was able to do it with this code <td width=\200\" align=\"center\"><input type=\"text\" name=\"adult$j\" value=\"$adult\" size=\"6\"></td> in a loop and using this on form submit if(@$_POST['submit1']) $btn=1; and so on up to $btn=6; the thing is for this i know exactly (max) how many rows would be displayed so i have set a max of 6 form submit validation using if(@$_POST['submit1']) $btn=1; to identify which button was clicked. My current task is that I wouldn't know how many rows would be displayed but I still need to know which submit button was clicked. I can still use the previous code in a loop to create the submit buttons and it worked. It printed out 1 submit button for each row of record as I wanted. I need help on the submit part coz I really don't know how to identify the "actual" submitted button. Is there a way for me to identify which button was clicked from n number of rows/button? or is there a better work around for this? each button is to update individual records based on ID and which table is it from using single sql as below. $sql="UPDATE $tbl SET MembershipNumber=$memnumber WHERE MemberID=$id"; please help me out.
  6. great work of creative art there barand. i got your point.. thanks
  7. Aahh you are right again.. 2 members with same family name.? Changed the Family name and all 120 records appear grouped by family.. Thanks a lot Barand this is now officially closed
  8. i have done all the adjustment to the data(record) but still one particular name from tblmember does not print out using your code. but if i run the filter from the database (MembershipType=1) that name appears in the list. And if i use another query count(MemberName) WHERE MembershipType=1 that particular person is included in the total from table tblmember (54 records). Strange!! I have a function to count total members filtered (MembershipType=1) for each table and this is what i get tblmember - 54 tblspouse - 24 tblchildren - 42 Total=120 but total printout on the page is 119 (short of that same particular person) is there anything that i'm missing??
  9. I'm not getting the result correctly though it does filter by membership & group by family. After some manual validation check, I found that this query does displays 2repeated results from tblchildren of the same family and did miss out a few. my result :$membership=1; Actual result: tblmember=55 tblspouse=24 tblchildren=41 Total=120 but display: tblmember=51 (missed out 5) tblspouse=24 tblchildren=43 (repeat 2 and missed out 1) total=118 (including 2 repeat) my bad.. your code is good.. it was due to the data structure itself not your query.. it is simply superb. Thanks alot Barand. this is now solved.
  10. I'm not getting the result correctly though it does filter by membership & group by family. After some manual validation check, I found that this query does displays 2repeated results from tblchildren of the same family and did miss out a few. my result :$membership=1; Actual result: tblmember=55 tblspouse=24 tblchildren=41 Total=120 but display: tblmember=51 (missed out 5) tblspouse=24 tblchildren=43 (repeat 2 and missed out 1) total=118 (including 2 repeat)
  11. aahh.... join condition use AND not WHERE.. my bad...i've been trying with WHERE clause in join condition... anyway it did the job my friend.. mission accomplished.. thanks..
  12. You query is good but i just realized that your in query tblspouse and tblchildren depends on the where clause of tblmember for the MembershipType field. So it produces incorrect records though it was a good improvement where it grouped in families. Each table has their own MembershipType. for example a child may not be the same membership as its father and the same goes to spouse. How do I insert the where clause for each table to have MembershipType=$membership. All three tables are filtered by MembershipType=$membership then grouped by tblmember.FamilyName. Good tweak and great accomplishment. Hope you could help me more in this issue..
  13. all three tables has many fields but only 3 are to be selected MemberName FamilyName MembershipType MembershipType is user select from dropdown menu. The result should show the MemberName from each tables grouped by FamilyName based on the MembershipType selected by user.
  14. Hi phpfreaks, need help on the issue. Im trying to get records of family (tblmember,tblspouse,tblchildren) all extracted based on two fileds (FamilyName,MembershipType) where FamilyName is from the tblmember.FamilyName and MembershipType (for all three tables) is user input ($membership) i have tried all (joins) but i do not get the result that i want my code 1: SELECT tblmember.*,tblspouse.*,tblchildren.* FROM tblmember,tblspouse,tblchildren WHERE tblspouse.FamilyName=tblmember.FamilyName AND tblchildren.FamilyName=tblmember.FamilyName AND tblmember.MembershipType=$membership AND tblspouse.MembershipType=$membership AND tblchildren.MembershipType=$membership ORDER BY tblmember.FamilyName ASC code 1 returns only records from tblchildren ( which is tblchildren.MemberName field) code 2: SELECT * FROM tblchildren JOIN tblspouse ON tblchildren.FamilyName=tblspouse.FamilyName INNER JOIN tblmember ON tblmember.FamilyName=tblchildren.FamilyName WHERE tblmember.MembershipType=$membership AND tblspouse.MembershipType=$membership AND tblchildren.MembershipType=$membership ORDER BY tblmember.FamilyName ASC returns only records from tblmember for the n number of records in tblchildren (tblchildren has 37 records and the result return will be 37 number of tblmember.MemberName) Code 3: SELECT tblmember.MemberName as `a`, tblmember.MembershipType, tblmember.FamilyName, tblspouse.MemberName as `b` , tblspouse.MembershipType, tblspouse.FamilyName, tblchildren.MemberName as `c`,tblchildren.MembershipType,tblchildren.FamilyName FROM tblspouse JOIN tblmember LEFT JOIN tblchildren ON tblchildren.FamilyName=tblmember.FamilyName WHERE tblmember.MembershipType=$membership"; Code 3 somehow manage to group by family but it shows in repeated manner where tblmember.MemberName of family-1 still appear with family-2 tblspouse.MemberName and family-1 tblchildren.MemberName (and more mixed-up families). My records are displayed in tabled format where each family is group in one row. I want to display all the records from all 3 tables grouped by FamilyName where MembershipType=$membership how can i accomplish this? currently im using 3 different queries to extract first query extract from tblmember where MembershipType=$membership second query extract from tblspouse where MembershipType=$membership thrid query extract from tblchildren where MembershipType=$membership Is there a better way to combine all 3 queries into 1 which groups the result by field FamilyName? Each family members appear in the same row of the table. Hope i didn't confuse y'all
  15. adding the 4th range will create a new paragraph which i don't want... unless if there is a guide on how to create 4th range at the end of 3th range then I will definitely take that option
  16. Hi guys, I'm trying to export records from php to ms word which appends text + image. i have got this code from http://www.thaicreate.com/php/php-word.application-addpicture.html <html> <head> <title>ThaiCreate.Com PHP Word.Application Tutorial</title> </head> <body> <? $wdColorDarkRed = "&H80"; $wdAlignParagraphCenter = "1"; $wdAlignParagraphLeft = "0"; $wdParagraph = "4"; $wdHorizontalPositionMargin = "0"; $wdTableLeft = "-999998"; $wdCollapseEnd = "0"; $Wrd = new COM("Word.Application"); $DocName = "MyDoc/MyWord.doc"; //$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp $Wrd->Application->Visible = False; $WrdDoc = $Wrd->Documents->Add(); $MyRange1 = $WrdDoc->Paragraphs->Add->Range; $MyRange1->ParagraphFormat->Alignment = $wdAlignParagraphCenter; $MyRange1->Font->Name = "Verdana"; $MyRange1->Font->Size = "30"; $MyRange1->Font->Bold = True; $MyRange1->InsertBefore(chr(13).chr(13)."www.ThaiCreate.Com".chr(13)."Version 2009"); $MyRange1->InlineShapes->AddPicture(realpath("thaicreate-2009.gif")); //$WrdDoc->InlineShapes->AddPicture(realpath("thaicreate-2009.gif")); //$WrdDoc->Shapes->AddPicture(realpath("thaicreate-2009.gif"),0,0,MyRange1); //$WrdDoc->Shapes->AddPicture(realpath("thaicreate-2009.gif"),0,0,Wrd->Selection->Range); $MyRange2 = $WrdDoc->Paragraphs->Add->Range; $MyRange2->ParagraphFormat->Alignment = $wdAlignParagraphCenter; $MyRange2->Font->Name = "Verdana"; $MyRange2->Font->Size = "15"; $MyRange2->Font->Bold = True; $MyRange2->InsertBefore(chr(13).chr(13)."PHP,ASP and ASP.NET Tutorial"); $MyRange2->InlineShapes->AddPicture(realpath("doc.gif")); $MyRange3 = $WrdDoc->Paragraphs->Add->Range; $MyRange3->ParagraphFormat->Alignment = $wdAlignParagraphCenter; $MyRange3->Font->Name = "Verdana"; $MyRange3->Font->Size = "10"; $MyRange3->Font->Bold = True; $MyRange3->Font->Color = $wdColorDarkRed; $MyRange3->Underline = True; $MyRange3->InsertBefore(chr(13).chr(13).chr(13).chr(13)."All Rights Reserved"); //$WrdDoc->SaveAs($strPath."/".$DocName); $WrdDoc->SaveAs(realpath($DocName)); $Wrd->Application->Quit; $Wrd = null; ?> Word Created <a href="<?=$DocName?>">Click here</a> to Download. </body> </html> This is the best code i've found so far that guides on how to format the text in ms word via PHP. All set to go but one thing that I am trying to accomplish : to have a clickable email address (hyperlink) in the same ms word file. i have got this code somewhere from the net: $MyRange3->Hyperlinks->Add({range}, 'http://www.google.com', '','',' hyperlink text to display'); // where {range} refers to as anchor according to that website this methods could be found in ms word visual basic editor (Alt+F11) then object browser (F2) when i replace the {range} above with let say variable $MyRange3. $MyRange3->Hyperlinks->Add($MyRange3, 'http://www.google.com', '','',' hyperlink text to display'); The output will be produced but overwriting everything in $MyRange3 and displays only the hyperlink. I would like the email address (hyperlink) to appear at the end of $MyRange3 text. example output All right reserved [u]hyperlink text to display[/u] anyone can shed some light on this.
  17. Thanks l0gic for lengthy and well explained theory. I think i will stick with your theory for the update of "IP status" using date. I do have a table for IP list, now i have to add in another 2 more field as you mentioned. my vbs file does not send data all the time, it only send when i click submit button after the vbs script has produced the HTML file and even if the user click on submit it will not be updated as my key field is the MAC address of the machine and it will cut-off before it reaches the INSERT INTO sql query if it detects a duplicate MAC Address entry plus my inventory system has a user login security feature where only "admin" level will be able to Add/Edit/Delete records and "User" level only able to view records. No direct access to any php page without login details. kicken, Thanks for the info on PHP ability based on my request. I only have records of assigned IP list in a table, i just wanted to differentiate between vacant,turned-off,turned-on machines. l0gics theory looks good to me. I will try it out and update this forum. Thanks to both of you. wait for my updates.
  18. Actually i have a PC-inventory system done in PHP. I have created a vbs file to run on individual PC to capture the details of the hardware (WMIC) info such as serial, brand,model,monitor brand,monitor serial,HD,RAM,Processor,IP address, MAC address, software name & license, printer connected to and printer port. This VBS file will export the result in HTML format and on submit button click the records will be updated into database based on MAC address as key field to minimize duplicate inventory. I was curious to find out if I could have a "IP lookup" function in the inventory system that i built in PHP where the system will generate a list of ip and indicate if its being assigned (PC turned off or PC turned on) and also indicate if the IP is vacant. Currently i can only identify the ip availability based on IP address that is in the database but could not show if its turned on or off or vacant. For example : I have assigned a IP address for a pc - and the pc is turned off. when i run the ip range search it will display the IP in ascending order and this particular IP will appear as "not in use". When i assign that particular IP to a new device it appears as "IP address Conflict". How do i solve this? please refer my screenshot.
  19. l0gic, thanks for the English lesson. I could understand the ping "reply" and "request time out". Just curious if a PC is assigned an IP address but it is turned of the reply would be returned as "request time out" (which is assigned but not vacant)? if an IP address is not assigned to any PC would the ping reply also return "request time out" (which is not assigned and vacant)? how to differentiate among the IP address (including those turned off pc)? Let say i enter an ip address to search its availability, can php "ping" or "other commands" to give the output as below: [*]IP address is available - not assigned to any PC/device [*]IP addres is assigned - the device is turned on [*]IP address is assigned - the device is turned off
  20. i have included the screenshot of my switch inventory using the above function
  21. I know that php has a function that can execute ping command but i'm not sure how it works. I am trying to get the result of the ping command to determine: [*]IP address has a reply (PC/device is turned on) [*]IP address has no reply (ip address is vacant and not assigned to any pc/device [*]IP address has a response (PC/device is turned off) is this "do-able" in php?? this is my script: function ping($ip){ // #5882FA blue color indicates Fiber Module // #FACC2E orange color indicates cascade/uplink cable // #81F781 Green color indicates connected/turned on // #FE2E2E Red color indicates disconnected/turned off // #585858 dark gray color indicates connected patch panel port is vacant at user side if($ip=="Cascade" OR $ip=="Uplink"){ return $status="style=\"background-color:#FACC2E;cursor:pointer;\""; /* orange */ }elseif ($ip=="Fibre Module"){ return $status="style=\"background-color:#5882FA;cursor:pointer;\""; /* blue */ }elseif ($ip==null or $ip==""){ return $status="style=\"cursor:pointer;background-image:url(images/x.gif);\""; /* dark gray */ }else{ $str = exec("ping -n 1 -w 1 $ip", $input, $result); if ($result == 0){ return $status="style=\"background-color:#81F781;cursor:pointer;\""; /* green */ //return "on"; }else{ return $status="style=\"background-color:#FE2E2E;cursor:pointer;\""; /* red */ //return "off"; } } } i can get it display on or off and i've tested it working. but i just can't figure out if i could use this command to determine if the IP address is vacant or unassigned. I'm using this for a IP list inventory system built in PHP. I have careted a page where the the 3com switch is drawn in tabulated format with each port assigned (via PHP) to the corresponding IP address of the device/PC and indicates the port color as described in the above function. Surprisingly it works well for this switch inventory. I just want to create another page for IP address inventory using the same function. To put is simple i want to have the same function as the sofware "Advance IP-Scanner" which does the same thing as well only thing is my resources are limited to PHP (WAMP). any help guys?
  22. Finally i got it resolved thanks to sasa for contributing a superb code to generate sql query based on user input and export to file with a download file option, http://www.phpfreaks.com/forums/index.php/topic,155530.0.html I did lots of changes to the code to meet my UNION table of 3 and export to xls instead of csv. here is my code not sure if its elegant but it works for me...hope this will help others who look in google .. $MembershipType='9'; $select_cols="MemberID, MemberName, MemberIC , FamilyName, MembershipType"; function convert_to_xls( $first_row , $null_to = 'NULL') { global $select_cols; global $MembershipType; $sql="SELECT ".$select_cols." FROM tblmember WHERE `MembershipType` ='$MembershipType' UNION (SELECT ".$select_cols." FROM tblspouse WHERE `MembershipType` ='$MembershipType' ) UNION (SELECT ".$select_cols." FROM tblchildren WHERE `MembershipType` ='$MembershipType')"; $result =mysql_query($sql) or die ("ERROR - unable to connect to table<br>".mysql_error()); $num=mysql_num_rows($result); $out = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\"> <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> <meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\" /> <style id=\"Classeur1_16681_Styles\"> </style> </head> <body> <div id=\"Classeur1_16681\" align=center x:publishsource=\"Excel\"> <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>\n <TR>\n"; $result1 = mysql_fetch_array($result); $result= explode(',', $select_cols); $n=0; foreach($result as $field){ $f_name[] = trim($field);; $out .=$first_row ? '<td class=xl2216681 nowrap><b>'.trim($field).'</b></td>'."\n" : ''; $n++; //number of columns to retrieve from table } $out .= $first_row ? "</tr>\n" : ''; $i=1;$j=1; $result =mysql_query($sql); $cols= explode(',', $select_cols); while ($row=mysql_fetch_array($result)){ for($j=0;$j<$n;$j++){ //number of columns to display per row $rec_data=$row[$j]; if($j==$n){ $out .= '<td class=x12216681 nowrap>'.$rec_data.'</td>'; }elseif($j==0){ $out .= '<tr>'."\n".'<td class=x12216681 nowrap>'.$rec_data.'</td>'."\n"; }else{ $out .= '<td class=x12216681 nowrap>'.$rec_data.'</td>'."\n"; } } } return $out .= '</table> </div> </body> </html>'; } $hr = true; // : false; $file = "membership.xls"; if ($file){ $fp = fopen($file, 'w'); fwrite($fp ,convert_to_xls($hr,"NULL")); fclose($fp); echo '<hr /><a href="',$file,'">Download</a> Excel spreadsheet'; } else echo '<hr />No file name'; echo convert_to_xls($hr,"NULL"); Thank you phpfreak forum and sasa, and batwimp.
  23. thanks for prompt reply batwimp. i have tried as combining my two queries as how you suggested and i get an error my sql query is $searchsql="SELECT MemberID, MemberName, MemberIC , FamilyName, MembershipType FROM tblmember WHERE `MembershipType` ='$MembershipType' UNION (SELECT MemberID, MemberName, MemberIC, FamilyName, MembershipType FROM tblspouse WHERE `MembershipType` ='$MembershipType' ) UNION (SELECT MemberID, MemberName, MemberIC , FamilyName, MembershipType FROM tblchildren WHERE `MembershipType` ='$MembershipType') INTO OUTFILE '$filelocation' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' ORDER BY MemberName ASC ";
  24. Dear freak gurus out there, I'm new to php and sql as i learn from online examples . Though there are lots of links and answers out there related to my post but none reflects what i need. You guys my only hope. what i'm trying to accomplish: i have 3 tables (tblmember,tblspouse,tblchildren) for family details and contact record which UNION with field:FamilyName. tblmember consists of additional 5 fields for contacts details such as address,postal,state,etc. Each tables also has a field for membership status field:MembershipType. i would like to generate a "report" in csv format where the records are exported based on membership status selected from the dropdown list on the reports.php page. Once clicked on the submit button the query will do the "magic sql" to capture the selected fields from all the 3 tables based on MembershipType = $_POST['dropdownlist'] I have done a search query using UNION where the user enters anypart of the "member name" and the query will look into field:MemberName in all 3 tables and displays the selected fields from all 3 tables onto the page itself (no export). can i combine the SELECT * INTO OUTFILE with UNION? as i received an error "incorrect usage of UNION and INTO". so how do i use UNION with SELECT INTO OUTFILE? and is this the right way? i have run 2 separate test query: 1) with UNION works well on all 3 tables just to print on page in tabulated format 2) with INTO OUTFILE works well to export only with one table is there a way to have 1 query to do the both?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.