PHP - Data Mining / Extraction From Web
I am in the process of teaching myself PHP/MySQL. I have taught myself other programming languages in the past so its not that i can't learn. but as i'm new and trying to learn both at the same time, i'm needing some help with php / mysql to datamine either of the following sites.
www.findchips.com www.eciaauthorized.com WHat i want to do is after putting in the part number, for each distributor that returns data i want to extract the following data for each distributor Quantity Break Resale at quantity break Current Stock I want to write the data into a field in the database that holds the p/n's and my company's resale. I'm wanting to do this as an exercise so that i can dynamically benchmark my resales against that of my competitors. To get a feel of the data that is returned, please use the following p/n. 1n4001-e3/54 any and all help would be greatly appreciated Similar TutorialsHi all, I need to get all businesses including details from http://www.nswbusinesschamber.com.au/Business-directory.aspx?name=&location= . What is the best way to approach this? Are there any scripts out there? Thanks... My db table has columns "id" (int-11), "date(varchar-50)", "author name(varchar-100)", "text (varchar-100000)"... I am storing images + text in text field of database. Everything is going fine while i am using ckeditor to insert data into the database for that particular text field. Now when i am retrieving data from database... i am able to extract id, date, autorname successfully (i have check it while the issue came)..but when i am trying to retrieve text field which have image, that jumps to page not found error... what could be the issue... am i having problem with database or editor that i am using???? Hey, I have a script that is meant to grab links of a specific type. Code: [Select] <?php //need to some how extract all links from this text $link = '[quote]http://www.domain.com/?d=03WO6WPC random text, http://www.domain.com/?d=0334fWPChttp://www.domain.com/?d=03WV4SPC[/quote]'; ?> The urls are always the same character length, but there is no telling how the user types them out so im looking for a way to extract the 3 urls based on domain.com. The end result should be to create an array of 3 urls which belong to domain.com . I tried explode but some one may type it without spaces so explode fails.. any ideas? I currently have an array called: $find[pagetext] In this array, there is going to be one to several instances where I am looking for a specific forum coding called: [url=http://megaupload.com/?d=X]http://megaupload.com/?d=X[/url] Everyone has used megaupload but what this script basically is going to do is check the validity of the upload site the user has chosen. Above I selected megaupload but there are about 6 sites I am going to check in the code I'm writing. I'm stuck on 1 part. How can I extract from $find[pagetext] all occurances of the website (In this case) megaupload and assign each instance to array. Once I assign it to an array I've already written a function that will check and see if the web link is valid I just need to basically extract each URL occurance of megaupload or whatever the upload site I am checking there is. All help is greatly appreciated. OK, I just want to extract the agency name, complete address, and phone number from this mess : {"facilities": [ { "fclt_name":"BEACH & O'NEILL IN", "fclt_addr":"7520 GREENBACK LN", "fclt_city":"CITRUS HEIGHTS", "fclt_state":"CA", "fclt_zip":"95610", "tel_no":"916.676.0844", "fax_no":"916.676.0860", "fclt_url":"null", "fclt_lattd":"38.6781788", "fclt_longtd":"-121.289615", "fclt_ctgy_cd":"2", "fclt_distance":"3.26341268894218446122718887944106659512" }, { "fclt_name":"AMERICAN AIM AUTO", "fclt_addr":"5341 SAN JUAN AVE", "fclt_city":"FAIR OAKS", "fclt_state":"CA", "fclt_zip":"95628", "tel_no":"916.962.0401", "fax_no":"916.962.0414", "fclt_url":"null", "fclt_lattd":"38.6625015", "fclt_longtd":"-121.2922782", "fclt_ctgy_cd":"2", "fclt_distance":"3.50675708898608342216618250068171298694" }, { "fclt_name":"INSZONE INSURANCE", "fclt_addr":"7200 FAIR OAKS BLVD STE 210", "fclt_city":"CARMICHAEL", "fclt_state":"CA", "fclt_zip":"95608", "tel_no":"916.503.8784", "fax_no":"916.486.4335", "fclt_url":"null", "fclt_lattd":"38.631717", "fclt_longtd":"-121.327626", "fclt_ctgy_cd":"2", "fclt_distance":"4.01207784800582596431030369642981690151" }, { "fclt_name":"PARK FAMILY INS &", "fclt_addr":"801 RIVERSIDE AVE STE 100", "fclt_city":"ROSEVILLE", "fclt_state":"CA", "fclt_zip":"95678", "tel_no":"888.723.7275", "fax_no":"866.772.2912", "fclt_url":"null", "fclt_lattd":"38.732289", "fclt_longtd":"-121.289295", "fclt_ctgy_cd":"2", "fclt_distance":"4.47210016333570016664044149856001806252" }, { "fclt_name":"RK JACOBS INSURANC", "fclt_addr":"4777 SUNRISE BLVD STE B", "fclt_city":"FAIR OAKS", "fclt_state":"CA", "fclt_zip":"95628", "tel_no":"916.966.3733", "fax_no":"916.966.0177", "fclt_url":"null", "fclt_lattd":"38.6525671", "fclt_longtd":"-121.2728244", "fclt_ctgy_cd":"2", "fclt_distance":"4.75887214653382230652493164121477832758" }, { "fclt_name":"BERTOLINO INSURANC", "fclt_addr":"2985 FULTON AVE", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95821", "tel_no":"916.384.9621", "fax_no":"877.553.0066", "fclt_url":"null", "fclt_lattd":"38.6190831", "fclt_longtd":"-121.4015452", "fclt_ctgy_cd":"2", "fclt_distance":"5.50381610176691043722708919483708216851" }, { "fclt_name":"THE PEXA GROUP", "fclt_addr":"1221 PLEASANT GROVE BLVD", "fclt_city":"ROSEVILLE", "fclt_state":"CA", "fclt_zip":"95678", "tel_no":"916.788.4200", "fax_no":"916.788.4204", "fclt_url":"null", "fclt_lattd":"38.772237", "fclt_longtd":"-121.308503", "fclt_ctgy_cd":"2", "fclt_distance":"6.25871993199859278950600593840623920844" }, { "fclt_name":"PARAMOUNT EQUITY I", "fclt_addr":"8781 SIERRA COLLEGE BLVD", "fclt_city":"ROSEVILLE", "fclt_state":"CA", "fclt_zip":"95661", "tel_no":"877.284.2424", "fax_no":"888.811.2910", "fclt_url":"null", "fclt_lattd":"38.7424319", "fclt_longtd":"-121.2511908", "fclt_ctgy_cd":"2", "fclt_distance":"6.50250135161509994547872070619122902873" }, { "fclt_name":"PETERSON & GRANTHA", "fclt_addr":"1508 EUREKA RD STE 175", "fclt_city":"ROSEVILLE", "fclt_state":"CA", "fclt_zip":"95661", "tel_no":"916.431.0400", "fax_no":"916.431.0221", "fclt_url":"null", "fclt_lattd":"38.749593", "fclt_longtd":"-121.250556", "fclt_ctgy_cd":"2", "fclt_distance":"6.83036958706746253088617532680453999753" }, { "fclt_name":"INDEPENDENT SOL UN", "fclt_addr":"2723 ZINFANDEL DR", "fclt_city":"RANCHO CORDOVA", "fclt_state":"CA", "fclt_zip":"95670", "tel_no":"916.635.6760", "fax_no":"916.635.9804", "fclt_url":"null", "fclt_lattd":"38.5967846", "fclt_longtd":"-121.2894781", "fclt_ctgy_cd":"2", "fclt_distance":"7.03267554456276560054938083160853750814" }, { "fclt_name":"MORE CHOICES INS A", "fclt_addr":"1474 STONE POINT DR # 131", "fclt_city":"ROSEVILLE", "fclt_state":"CA", "fclt_zip":"95661", "tel_no":"916.899.6600", "fax_no":"916.647.0522", "fclt_url":"null", "fclt_lattd":"38.755322", "fclt_longtd":"-121.249216", "fclt_ctgy_cd":"2", "fclt_distance":"7.14043819089449986827741629585808532375" }, { "fclt_name":"ALBANO DALE DUNN &", "fclt_addr":"9197 GREENBACK LN", "fclt_city":"ORANGEVALE", "fclt_state":"CA", "fclt_zip":"95662", "tel_no":"916.988.0214", "fax_no":"916.989.4719", "fclt_url":"null", "fclt_lattd":"38.678737", "fclt_longtd":"-121.212147", "fclt_ctgy_cd":"2", "fclt_distance":"7.40385556560869808878938590652772224486" }, { "fclt_name":"MCGEE & THIELEN IN", "fclt_addr":"3780 ROSIN CT STE 120", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95834", "tel_no":"916.646.1919", "fax_no":"916.646.0995", "fclt_url":"null", "fclt_lattd":"38.636195", "fclt_longtd":"-121.473132", "fclt_ctgy_cd":"2", "fclt_distance":"7.57412262483417036891911065525086823482" }, { "fclt_name":"AGENTS RESOURCES I", "fclt_addr":"11190 SUN CENTER DR", "fclt_city":"RANCHO CORDOVA", "fclt_state":"CA", "fclt_zip":"95670", "tel_no":"916.443.4221", "fax_no":"916.443.5559", "fclt_url":"null", "fclt_lattd":"38.597237", "fclt_longtd":"-121.267659", "fclt_ctgy_cd":"2", "fclt_distance":"7.61684981655654181229982085243856553867" }, { "fclt_name":"STEVE C LUTH INS", "fclt_addr":"9480 MADISON AVE STE 1", "fclt_city":"ORANGEVALE", "fclt_state":"CA", "fclt_zip":"95662", "tel_no":"888.597.8383", "fax_no":"916.989.9102", "fclt_url":"null", "fclt_lattd":"38.6735726", "fclt_longtd":"-121.2007054", "fclt_ctgy_cd":"2", "fclt_distance":"8.053760009460164598304836725423812559" }, { "fclt_name":"MCDOWALL & KEENEY", "fclt_addr":"865 HOWE AVE STE 200", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95825", "tel_no":"916.567.3233", "fax_no":"916.567.3155", "fclt_url":"null", "fclt_lattd":"38.581372", "fclt_longtd":"-121.41588", "fclt_ctgy_cd":"2", "fclt_distance":"8.16424077949136484737583499892043887019" }, { "fclt_name":"SIERRA OAK INS SER", "fclt_addr":"9700 BUSINESS PARK DR STE 105", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95827", "tel_no":"916.364.7380", "fax_no":"916.364.7381", "fclt_url":"null", "fclt_lattd":"38.568104", "fclt_longtd":"-121.334623", "fclt_ctgy_cd":"2", "fclt_distance":"8.27507991633456734395325050580063137134" }, { "fclt_name":"RICHARD CHRISTOPHE", "fclt_addr":"5842 LONETREE BLVD", "fclt_city":"ROCKLIN", "fclt_state":"CA", "fclt_zip":"95765", "tel_no":"916.626.3305", "fax_no":"916.471.0311", "fclt_url":"null", "fclt_lattd":"38.8065456", "fclt_longtd":"-121.293125", "fclt_ctgy_cd":"2", "fclt_distance":"8.76951297025304552186130788422901665504" }, { "fclt_name":"ADEPT INSURANCE SE", "fclt_addr":"101 PARKSHORE DR STE 30061", "fclt_city":"FOLSOM", "fclt_state":"CA", "fclt_zip":"95630", "tel_no":"916.944.2192", "fax_no":"866.529.5303", "fclt_url":"null", "fclt_lattd":"38.6570589", "fclt_longtd":"-121.186783", "fclt_ctgy_cd":"2", "fclt_distance":"8.9960609261835699863946424309422450653" }, { "fclt_name":"PARAGON INSURANCE", "fclt_addr":"301 NATOMA ST STE 104", "fclt_city":"FOLSOM", "fclt_state":"CA", "fclt_zip":"95630", "tel_no":"916.353.1023", "fax_no":"916.353.1370", "fclt_url":"null", "fclt_lattd":"38.678047", "fclt_longtd":"-121.168827", "fclt_ctgy_cd":"2", "fclt_distance":"9.73781780936977222523189878525699239046" }, { "fclt_name":"CLINTON POLLEY GRO", "fclt_addr":"1675 CREEKSIDE DR STE 100", "fclt_city":"FOLSOM", "fclt_state":"CA", "fclt_zip":"95630", "tel_no":"916.984.3000", "fax_no":"916.984.3100", "fclt_url":"null", "fclt_lattd":"38.6716438", "fclt_longtd":"-121.1446657", "fclt_ctgy_cd":"2", "fclt_distance":"11.07358533782419719432038848742812184727" }, { "fclt_name":"ALPHA BOND INSURAN", "fclt_addr":"3918 60TH ST", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95820", "tel_no":"866.313.3077", "fax_no":"916.429.7974", "fclt_url":"null", "fclt_lattd":"38.5393731", "fclt_longtd":"-121.4344591", "fclt_ctgy_cd":"2", "fclt_distance":"11.21762941497442801416098309046154379963" }, { "fclt_name":"HEBARD INSURANCE A", "fclt_addr":"3837 TAYLOR RD", "fclt_city":"LOOMIS", "fclt_state":"CA", "fclt_zip":"95650", "tel_no":"916.652.0404", "fax_no":"916.652.9123", "fclt_url":"null", "fclt_lattd":"38.81657", "fclt_longtd":"-121.197889", "fclt_ctgy_cd":"2", "fclt_distance":"12.08374482196660408349940289432841322946" }, { "fclt_name":"PILCHER INSURANCE", "fclt_addr":"3805 TAYLOR RD STE 1", "fclt_city":"LOOMIS", "fclt_state":"CA", "fclt_zip":"95650", "tel_no":"916.660.1670", "fax_no":"916.660.1672", "fclt_url":"null", "fclt_lattd":"38.817032", "fclt_longtd":"-121.197206", "fclt_ctgy_cd":"2", "fclt_distance":"12.13211505726556203701939114285606195057" }, { "fclt_name":"RUSSELL VANG INS &", "fclt_addr":"2751 FRUITRIDGE RD STE 15", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95824", "tel_no":"916.428.2267", "fax_no":"916.428.2341", "fclt_url":"null", "fclt_lattd":"38.517011", "fclt_longtd":"-121.4513314", "fclt_ctgy_cd":"2", "fclt_distance":"13.00258097375703227426814846084345607012" }, { "fclt_name":"PC INSURANCE AGENC", "fclt_addr":"6333 STOCKTON BLVD STE A", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95824", "tel_no":"916.391.5990", "fax_no":"916.391.5993", "fclt_url":"null", "fclt_lattd":"38.5111875", "fclt_longtd":"-121.4360945", "fclt_ctgy_cd":"2", "fclt_distance":"13.04926930736758364287316544823571444809" }, { "fclt_name":"GOLDENBEST INSURAN", "fclt_addr":"6830 STOCKTON BLVD # 100", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95823", "tel_no":"916.231.9955", "fax_no":"916.231.9954", "fclt_url":"null", "fclt_lattd":"38.502632", "fclt_longtd":"-121.43303", "fclt_ctgy_cd":"2", "fclt_distance":"13.54608070539524090996150854589636455506" }, { "fclt_name":"EDWARD C BRODIE IN", "fclt_addr":"2379 GATEWAY OAKS DR STE 150", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95822", "tel_no":"916.927.6343", "fax_no":"916.927.8848", "fclt_url":"null", "fclt_lattd":"38.5128714", "fclt_longtd":"-121.4970294", "fclt_ctgy_cd":"2", "fclt_distance":"14.46565232261373440674810015002201060961" }, { "fclt_name":"LINH DO INSURANCE", "fclt_addr":"6511 SAVINGS PL STE 115", "fclt_city":"SACRAMENTO", "fclt_state":"CA", "fclt_zip":"95828", "tel_no":"916.393.8383", "fax_no":"916.393.8382", "fclt_url":"null", "fclt_lattd":"38.4739858", "fclt_longtd":"-121.3884671", "fclt_ctgy_cd":"2", "fclt_distance":"14.89569563450147516294105371450235166475" }, { "fclt_name":"STRATTON AGENCY", "fclt_addr":"957 INDUSTRIAL RD STE C", "fclt_city":"SAN CARLOS", "fclt_state":"CA", "fclt_zip":"95762", "tel_no":"650.508.0124", "fax_no":"650.508.0121", "fclt_url":"null", "fclt_lattd":"38.6637192", "fclt_longtd":"-121.067907", "fclt_ctgy_cd":"2", "fclt_distance":"15.24924065635783489201051962237991277729" }, { "fclt_name":"PACIFIC INTERSTATE", "fclt_addr":"5072 HILLSDALE CIR STE 110", "fclt_city":"EL DORADO HILLS", "fclt_state":"CA", "fclt_zip":"95762", "tel_no":"916.941.0518", "fax_no":"916.941.0547", "fclt_url":"null", "fclt_lattd":"38.621938", "fclt_longtd":"-121.062804", "fclt_ctgy_cd":"2", "fclt_distance":"16.0891004210135393693458563137933030129" }, { "fclt_name":"AMAZING INSURANCE", "fclt_addr":"8398 LAPORTE WAY", "fclt_city":"ELK GROVE", "fclt_state":"CA", "fclt_zip":"95624", "tel_no":"916.719.6449", "fax_no":"916.258.6679", "fclt_url":"null", "fclt_lattd":"38.445406", "fclt_longtd":"-121.394576", "fclt_ctgy_cd":"2", "fclt_distance":"16.89751994304863412037777682922840849653" }, { "fclt_name":"WAHLA INSURANCE &", "fclt_addr":"4809 LAGUNA BLVD STE 100", "fclt_city":"ELK GROVE", "fclt_state":"CA", "fclt_zip":"95758", "tel_no":"916.429.4741", "fax_no":"916.429.4743", "fclt_url":"null", "fclt_lattd":"38.424506", "fclt_longtd":"-121.449703", "fclt_ctgy_cd":"2", "fclt_distance":"18.95918985420010413223068782438653209117" }, { "fclt_name":"MOTHER LODE INS SE", "fclt_addr":"2514 CAMEO DR STE A", "fclt_city":"CAMERON PARK", "fclt_state":"CA", "fclt_zip":"95682", "tel_no":"530.677.8755", "fax_no":"530.677.8314", "fclt_url":"null", "fclt_lattd":"38.6578609", "fclt_longtd":"-120.999481", "fclt_ctgy_cd":"2", "fclt_distance":"18.96331840626573060295348092634463597585" }, { "fclt_name":"WOODEL INSURANCE", "fclt_addr":"8788 ELK GROVE BLVD STE P", "fclt_city":"ELK GROVE", "fclt_state":"CA", "fclt_zip":"95624", "tel_no":"916.714.5122", "fax_no":"916.714.5123", "fclt_url":"null", "fclt_lattd":"38.408374", "fclt_longtd":"-121.377051", "fclt_ctgy_cd":"2", "fclt_distance":"19.33537262024884176605153693999802777133" }, { "fclt_name":"AMAN INSURANCE AGE", "fclt_addr":"8788 ELK GROVE BLVD BLDG 3", "fclt_city":"ELK GROVE", "fclt_state":"CA", "fclt_zip":"95624", "tel_no":"916.213.1900", "fax_no":"800.714.6082", "fclt_url":"null", "fclt_lattd":"38.408374", "fclt_longtd":"-121.377051", "fclt_ctgy_cd":"2", "fclt_distance":"19.33537262024884176605153693999802777133" }, { "fclt_name":"MULHOLLAND INSURAN", "fclt_addr":"2358 MARITIME DR STE 100", "fclt_city":"ELK GROVE", "fclt_state":"CA", "fclt_zip":"95758", "tel_no":"916.691.5555", "fax_no":"916.691.0555", "fclt_url":"null", "fclt_lattd":"38.413727", "fclt_longtd":"-121.483123", "fclt_ctgy_cd":"2", "fclt_distance":"20.24810658073937047943171540052851815376" }, { "fclt_name":"SILLECT INSURANCE", "fclt_addr":"100 KENTUCKY AVE", "fclt_city":"WOODLAND", "fclt_state":"CA", "fclt_zip":"95695", "tel_no":"530.662.9050", "fax_no":"888.613.5849", "fclt_url":"null", "fclt_lattd":"38.691387", "fclt_longtd":"-121.781223", "fclt_ctgy_cd":"2", "fclt_distance":"23.3148181263597264149496516029276053035" }, { "fclt_name":"VAUGHT WRIGHT & BO", "fclt_addr":"533 MAIN ST", "fclt_city":"PLACERVILLE", "fclt_state":"CA", "fclt_zip":"95667", "tel_no":"530.622.1835", "fax_no":"530.622.3860", "fclt_url":"null", "fclt_lattd":"38.7298", "fclt_longtd":"-120.798354", "fclt_ctgy_cd":"2", "fclt_distance":"29.83338181060752344743347837235784856168" }, { "fclt_name":"DARR INSURANCE AGE", "fclt_addr":"550 MAIN ST", "fclt_city":"PLACERVILLE", "fclt_state":"CA", "fclt_zip":"95667", "tel_no":"530.217.6002", "fax_no":"530.626.4590", "fclt_url":"null", "fclt_lattd":"38.728995", "fclt_longtd":"-120.797821", "fclt_ctgy_cd":"2", "fclt_distance":"29.85673424682092359769083672633797070566" } ] } hello, I am trying to figure out how I can take only the v= in the youtube urls http://www.youtube.com/watch?v=nGawAhRjtoA&feature=topvideos i just want php to take v=nGawAhRjtoA and ignore everything else any ideas guys/gals? thanks This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=353645.0 Hi everyone, I do not know if this is the right place to ask the following, but I know all the php guru's read here. So please take a moment to read and please help point me in the right direction. I have a php website that I am developing, it is a job website, where my problem is that I need to be able to extract text from the following file formats: doc, docx, rtf, txt and maybe pdf. I have googled and done research on this subject, but I do not find any php scripts that can do the job properly. I have found a java app developed by apache that does the text extraction perfectly, called apache tika. (calling it using exec is really a problem, since most hosts don't provide root access.) I need a way to use this with php. If you know of any other method that I can do this, please help and suggest as this is a major bridge that I have to cross very urgently. your help will be much appreciated, thanks Problem: I'm trying to build a junction table for a many to many relationship. Table A contains a title string that contains in it names that are stored in Table B. Both tables have nearly a million rows. Bad solution: The method I'm using right now is using PHP I fetch and store one table into an associative array. I then do a mysql_fetch loop on the second table and run this code to populate an array that is used to build the multi-insert SQL. $title = preg_replace ($names, $keys, $title); if (preg_match_all ('/(\d+)/', $title, $matches)) foreach ($matches[1] as $m) $inserts[$row['id'].'-'.$m] = 1; This works, but I'm looking for possibly a less cpu/memory intensive method. My remote server can't handle it, and we're talking hours and hours on a local server. It seems the bottleneck is with the preg_replace. I've also tried str_replace, which is only slightly faster. So, a method where I wouldn't have to pass around such large arrays, or an entirely different approach is what I'm looking for. Any ideas? hello, i want to extract the sender_id, sender_alias and text from the array that should be returned when requesting access to direct messages via API. I get the error "Fatal error: Call to undefined method TwitterOAuth::request() " referring to the line $direct_message = $OAuth->request('GET', $OAuth->url('https://api.twitter.com/1/direct_messages.json'), array('sender_id','screen_name' ,'text')); Code: [Select] // create new instance $OAuth = new TwitterOAuth($consumer_key,$consumer_secret, $oAuthToken, $oAuthSecret); $direct_message = $OAuth->request('GET', $OAuth->url('https://api.twitter.com/1/direct_messages.json'), array('sender_id','screen_name' ,'text')); $direct_message = json_decode($OAuth->response['response'], true); echo response; Am new here - looks like a great foru! I would sincerely appreciate any help anyone can give me. I have been trying to solve my problem for hours and I am not having any luck, so I thought I would post and see if anyone can help. I am very stuck and am not making much progress on this project, and I am certain the answer is very simple. I am constructing a form to collect data for a specialized purpose. The form and program actually work for its intended function, but I am trying to enhance the user experience by preventing customers from having to reenter all of their data should there be a problem with any of the data submitted. I have been able to do that with the contact form portion, but what I am having trouble with is the portion which has as many as 400 possible entries. So, in a nutshell, if the customers contact data is incomplete or in error, the form will ask them to return to the page and correct things. The previous data entered has been saved in the session and the input value will equal the previous entry. i.e. <tr> <td align="right" class="infoBox"><?php echo ENTRY_EMAIL_ADDRESS; ?></td> <td align=left><?php echo "<input type=text name='cemail' value=\"$cemail\" size=35 maxlength=35>" ?></td> </tr> Works perfectly, all well and good there. On the other 400 more or less entries, I am having a difficult time tweaking the string concatenation to work to achieve similar results. There are 4 columns each with $points entries asking for a dimension in either feet or inches. The <input name=> is one of ptaf,ptai,ptbf,ptbi, appended programatically with the corresponding row number or data point. i.e. "ptaf1", "ptai1", etc... This is produced by the example below and works perfectly also. <?php { $points=100; $i=1; while ($i <= $points) {echo ' <tr><td align="center" width="6"><b> ' .$i . '</b></td> <td align="right" NOWRAP>A' .$i . ' (ft) <input type="text" name="ptaf'.$i.'" size=4 maxlength=3> </td> <td align="right" NOWRAP>A' .$i . ' (in) <input type="text" name="ptai'.$i.'" size=4 maxlength=4> </td> <td align="right" NOWRAP>B' .$i . ' (ft) <input type="text" name="ptbf'.$i.'" size=4 maxlength=3> </td> <td align="right" NOWRAP>B' .$i . ' (in) <input type="text" name="ptbi'.$i.'" size=4 maxlength=4> </td> '; $i++; } } ?> I am trying to add <input value=$ptai.$i> for each field but as I mentioned I am not having any luck. It seems as if I have tried every combination imagineable, but still no luck. My head is spinning! The closest I seem to have gotten was with this: <td align="right" NOWRAP>A' .$i . ' (ft) <input type="text" size=6 maxlength=3 name="ptaf'.$i.'" value="' . "$ptaf" . $i . '" ></td> But line 17 for example returns this: <input type="text" value="17" name="ptaf17" maxlength="3" size="6"> To recap, I am trying to have the value set to whatever the customer may have entered previously. Again, I would most appreciate any help anyone can give me. If you need clarification on anything please let me know. Thanks AJ Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. Here's the code that deals with the client side:
<?php session_start(); if(!isset($_SESSION['Logged_in'])){ header("Location: /page.php?page=login"); } ?> <!DOCTYPE Html> <html> <head> <!--Connections made and head included--> <?php require_once("../INC/head.php"); ?> <?php require_once("../Scripts/DB/connect.php"); ?> <!--Asynchronously Return User Names--> <script> $(document).ready(function(){ function search(){ var textboxvalue = $('input[name=search]').val(); $.ajax( { type: "GET", url: 'search.php', data: {Search: textboxvalue}, success: function(result) { $("#results").html(result); } }); }; </script> </head> <body> <div id="header-wrapper"> <?php include_once("../INC/nav2.php"); ?> </div> <div id="content"> <h1 style="color: red; text-align: center;">Member Directory</h1> <form onsubmit="search()"> <label for="search">Search for User:</label> <input type="text" size="70px" id="search" name="search"> </form> <a href="index.php?do=">Show All Users</a>|<a href="index.php?do=ONLINE">Show All Online Users</a> <div id="results"> <!--Results will be returned HERE!--> </div>search.php <?php //testing if data is sent ok echo "<h1>Hello</h1><br>" . $_GET['search']; ?>This is the link I get after sending foo. http://www.family-li...php?&search=foo Is that mean it was sent, but I'm not processing it correctly? I'm new to the whole AJAX thing. I have two tables. Table Name:Users Fields: User_name user_email user_level pwd 2.Reference Fields: refid username origin destination user_name in the users table and the username field in reference fields are common fields. There is user order form.whenever an user places an order, refid field in reference table will be updated.So the user will be provided with an refid Steps: 1.User needs to log in with a valid user id and pwd 2.Once logged in, there will be search, where the user will input the refid which has been provided to him during the time of order placement. 3.Now User is able to view all the details for any refid 3.Up to this we have completed. Query: Now we need to retrieve the details based on the user logged in. For eg: user 'USER A' has been provided with the referenceid '1234' during the time of order placement user 'USER B' has been provided with the referenceid '2468' during the time of order placement When the userA login and enter the refid as '2468' he should not get any details.He should get details only for the reference ids which is assigned to him. <?php session_start(); if (!$_SESSION["user_name"]) { // User not logged in, redirect to login page Header("Location: login.php"); } $con = mysql_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $user_name = $_POST['user_name']; $refid = $_POST['refid']; $query = "SELECT * from reference,users WHERE reference.username=users.user_name AND reference.refid='$refid' AND "; $result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query); while($row = mysql_fetch_array($result)) { echo $row['refid']; echo $row['origin']; echo $row['dest']; echo $row['date']; echo $row['exdate']; echo $row['username']; } echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> <html> <form method="post" action="final.php"> Ref Id:<input type="text" name="refid"> <input type="submit" value="submit" name="submit"> </html> Say there is a complex opt in process where people start to enter their data but certain questions stop them where they close out of the page. They already entered their data and I feel there is a way to grab it and post it to mysql even though they do not click submit.
How would this be done?
A super simple example (proof of concept) or a link to a tutorial would be very useful.
Edited by brentman, 23 September 2014 - 10:42 AM. Hi, after banging my head against the wall for a while thinking this would be a simple task, I'm discovering that this is more complicated than I thought. Basically what I have is a link table linking together source_id and subject_id. For each subject there are multiple sources associated with each. I had created a basic listing of sources by subject... no problem. I now need a way of having a form to create an ordered list in a user-specified way. In other words, I can currently order by id or alphabetically (subject name lives on a different table), but I need the option of choosing the order in which they display. I added another row to this table called order_by. No problem again, and I can manage all of this in the database, however I want to create a basic form where I can view sources by subject and then enter a number that I can use for sorting. I started off looping through each of the entries and the database (with a where), and creating a foreach like so (with the subject_id being grabbed via GET from the URL on a previous script) Code: [Select] while($row = mysqli_fetch_array($rs)) { //update row order if (isset($_POST['submit'])) { //get variables, and assign order $subject_id = $_GET['subject_id']; $order_by = $_POST['order_by']; $source_id = $row['source_id']; //echo 'Order by entered as ' . $order_by . '<br />'; foreach ($_POST['order_by'] as $order_by) { $qorder = "UPDATE source_subject set order_by = '$order_by' WHERE source_id = '$source_id' AND subject_id = '$subject_id'"; mysqli_query($dbc, $qorder) or die ('could not insert order'); // echo $subject_id . ', ' . $order_by . ', ' . $source_id; // echo '<br />'; } } else { $subject_id = $_GET['subject_id']; $order_by = $row['order_by']; $source_id = $row['source_id']; } And have the line in the form like so: Code: [Select] echo '<input type="text" id="order_by" name="order_by[]" size="1" value="'. $order_by .'"/> (yes I know I didn't escape the input field... it's all stored in an htaccess protected directory; I will clean it up later once I get it to work) This, of course, results in every source_id getting the same "order_by" no matter what I put into each field. I'm thinking that I need to do some sort of foreach where I go through foreach source_id and have it update the "order_by" field for each one, but I must admit I'm not sure how to go about this (the flaws of being self-taught I suppose; I don't have anyone to go to on this). I'm hoping someone here can help? Thanks a ton in advance This could be PHP or MySql so putting it in PHP forum for now... I have code below (last code listed) which processes a dynamically created Form which could have anywhere from 0 to 6 fields. So I clean all fields whether they were posted or not and then I update the mySQL table. The problem with this code below is that if, say, $cextra was not posted (i.e. it wasnt on the dynamically created form), then this code would enter a blank into the table for $cextra (i.e. if there was already a value in the table for $cextra, it gets overwritten, which is bad). What is the best way to handle this? I'm thinking i have to break my SQL query into a bunch of if/else statements like this... Code: [Select] $sql = "UPDATE cluesanswers SET "; if (isset($_POST['ctext'])){ echo "ctext='$ctext',"; } else { //do nothing } and so on 5 more times.... That seems horribly hackish/inefficient. Is there a better way? Code: [Select] if (isset($_POST['hidden']) && $_POST['hidden'] == "edit") { $cimage=trim(mysql_prep($_POST['cimage'])); $ctext=trim(mysql_prep($_POST['ctext'])); $cextra=trim(mysql_prep($_POST['cextra'])); $atext=trim(mysql_prep($_POST['atext'])); $aextra=trim(mysql_prep($_POST['aextra'])); $aimage=trim(mysql_prep($_POST['aimage'])); //update the answer edits $sql = "UPDATE cluesanswers SET ctext='$ctext', cextra='$cextra', cimage='$cimage', atext='$atext', aextra='$aextra', aimage='$aimage'"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { } Hi, I've currently started to modify a chat script of mine to output a moderation panel but the moderation page seems empty(blank) every time I load it. What im trying to do is to take the ID part in my URL via the $_GET and look it up in my database table in the column named id, then select that specific row to be able to retrieve the StringyChat_ip and place it into another table to ban the IP and the second thing im trying to do is to be able to delete the specific row from my table.
My Http link look something like
http://imagecrab.fre.../ban.php?id=159
and my ban.php page where I want to lookup the 159 part and do the banning etc looks like
<? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_POST['id']; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_POST["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } $result = mysql_query("SELECT * FROM ".$dbTable." WHERE id='".$id."'",$db); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; $idm = $myrow["id"]; ?> <html> <form name="form<? echo $myrow["id"];?>" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $myrow["StringyChat_ip"];?>"> </form> </html> <? } ?> Hi I am trying to select and order data/numbers from a colum in a mysql data base however i run the code and it returns no value just a blank page no errors or any thing so i think the code is working right but then it returns no result? Please help thanks Here is the code: <?php $host= "XXXXXX"; $mysql_user = "XXXXXX"; $mysql_password = "XXXXXX"; $mysql_database = "XXXXXXX"; $connection = mysql_connect("$host","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server."); mysql_select_db($mysql_database) or die ("Unable to select requested database."); $row = mysql_fetch_assoc( mysql_query( "SELECT XP FROM Game ORDER BY number DESC LIMIT 1" ) ); $number = mysql_result(mysql_query("SELECT XP FROM Game ORDER BY number DESC LIMIT 1"), 0); echo "The the highest XP is $number"; ?> |