PHP - Pass Data To Next Php File
Hello, How can I get the id in the search bar into the viewuser.php file ... <?php foreach($myObjectMap as $key => $item): ?> <tr> <td> <a href="viewuser.php?id=<?PHP echo $item->ID; ?>"> <?PHP echo $item->UserName; ?> </td> ...
Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=359179.0 Hi ! I need to pass a lot of variables using GET, and many of them are related, so I was thinking in two options: 1) Pass them as array: Code: [Select] example.php?categories[]=cat1&categories[]=cat2 2) Pass them in a single parameter, and split it in PHP (a custom and simpler serializer) Code: [Select] example.php?categories=cat1|cat2 What do you think is better? (or maybe there is a 3rd option...) The second method seems more readable and short, the first easier to construct and maybe faster because we don't need to "unserialize". But I'm looking for better reasons. I'm thinking in a possible advantage of the first method over the second for SEO, because if Google is smart enough to understand that categories[] are all the same, then can understand that: Code: [Select] example.php?categories[]=cat1&categories[]=cat2is equal to: Code: [Select] example.php?categories[]=cat2&categories[]=cat1I think that is more difficult for Google to understand that with: Code: [Select] example.php?categories=cat1|cat2and Code: [Select] example.php?categories=cat2|cat1 Regards!! Enrique. Basically I am trying to make a list of items which I have put into an sql database. When I click on an item in the list, I want a "generic" page loaded, with the items description. Im having alot of trouble with getting this generic page to work. Heres what Ive done so far. The page with shows the list http://pastebin.com/PE8FkyYQ http://pastebin.com/GiCpV5AH The generic page with the items description. http://pastebin.com/HFnSfqN4 http://pastebin.com/C0zsHpZY If anyone can help me solve this problem, ill be greatly in there debt! Please tell me how can i do it ??
Hello all, I can't get the data store in the $ART_ID variable to pass into the database. The original $Artisan variable is set up like this: 1. Artisan Name. So the explode is taking just the number. If I put an echo after the explode and the $ART_ID variable it outputs the correct information but it doesn't store in the database as that data. The query is in correct order too. Thanks in advance. $CType_Type = $_REQUEST["CTYPE_Type"]; $Artisan = $_REQUEST['Artisan']; $Quantity = $_POST['Quantity']; $HAnswer1 = $_POST["HAnswer1"]; $HAnswer2 = $_POST["HAnswer2"]; $HAnswer3 = $_POST["HAnswer3"]; $HAnswer4 = $_POST["HAnswer4"]; $break = explode(".", $Artisan); $ART_ID = $break[0]; if(!$Quantity) { die('Quantity field is empty. Please enter the quantity of handicrafts made.'); } else { $ctypeQuery = mysql_query("SELECT CTYPE_ID FROM CraftType WHERE CTYPE_Type = '".$CType_Type."'"); while($row = mysql_fetch_array($ctypeQuery)) { $CTYPE_ID = $row["CTYPE_ID"]; $sql = ("INSERT INTO Handicraft VALUES (`HANDI_ID`, '".$Quantity."', 'NULL', '".$CTYPE_ID."', '".$ART_ID."', 'NULL', '1')"); if(!mysql_query($sql)) { die('Error inserting Handicraft Type into table: ' . mysql_error()); } else { -----data in this section doesn't affect the rest of the code---- } } } I am trying to send a file name to another php file, but am having trouble coming up with the best way to deal with the period between filename and extension. I have done a little reading on google and came up with 2 1/2 solutions... #1 - Pass the file name only and assume the extension later. This is good but limits what I can do in the future. #2 - Pass the file name and extension as different vars (ie phpfile.php?filename=foo&ext=bar) #3 - Write a function that changes the periods to an acceptable character and then convert it back in phpfile.php. I don't think this is such a great idea since you can have a file name like joe_vs_the_volcano.1988.txt or whatever. I was just wondering if anybody had any ideas and thoughts I am missing... Thanks Hi, Is there a way to send extracted information from one (local) MySQL db, via PHP, to an external web form - having that web form submit that info to it's connected MySQL db without human interaction? Basically, I need to automate a process using the $_GET function to that form but not sure if there is a way to accomplish this from just connecting to the web form (itself); bypassing direct MySQL access which is the later option. Any input appreciated - thanks! I'll be having .txt files uploaded via a form. Upon submission, it will be passed to another .php file to have the data entered into the database. It's not uploading the file to the folder, and while the trigger echoes what's set up to echo, it's loading the data into the database.
Here is the form: echo '<form action="/wp-content/plugins/csi_stats/csi_process.php" method="post" enctype="multipart/form-data"> Select Boxscore to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload" name="submit"> </form>'; } Here is csi_process.php $filename = $_FILES['fileToUpload']['name']; $target_dir = "/wp-content/uploads/csi_boxscores/21/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { // $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); echo $target_file . ' Boxscore Sent'; echo '<br>' .$filename; $uploadOk = 0; } $query = " LOAD DATA INFILE '$fileName' INTO TABLE a_stats FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n' IGNORE 2 Lines (jersey,points,2pm,2pa,3pm,3pa,ftm,fta,oreb,dreb,treb,ast,blk,stl,deflect,turn,charge,pf,tf) SET team = 426"; "team" will ultimately be a variable, and I'll have "game" in there too.
Here is the data: 235a5d12-be10-43af-abba-e45456d9d8da Jersey|Points|TwoPointsMade|TwoPointAttempts|ThreePointsMade|ThreePointAttempts|FreeThrowsMade|FreeThrowAttempts|OffensiveRebounds|DefensiveRebounds|Rebounds|Assists|BlockedShots|Steals|Deflections|Turnovers|Charges|PersonalFouls|TechnicalFouls 10|8|1|2|2|6|0|0|0|4|4|1|1|1|0|1|0|0|0 12|3|0|5|0|3|3|4|1|2|3|0|1|1|0|0|0|2|0 20|8|4|6|0|0|0|0|1|1|2|0|1|1|0|2|0|0|0 22|3|0|1|1|1|0|0|1|2|3|1|0|0|0|2|0|2|0 24|18|4|7|1|3|7|10|0|2|2|1|0|1|0|3|0|3|0 32|1|0|2|0|3|1|2|2|1|3|0|0|1|0|0|0|2|0 41|8|0|0|2|3|2|2|0|0|0|0|0|1|0|0|0|1|0 43|11|5|7|0|0|1|2|0|6|6|1|0|4|0|2|0|3|0 52|3|1|6|0|0|1|1|4|3|7|0|0|1|0|1|0|4|0 Edited November 14, 2020 by Jim R A beginner question.. I have tried "isset" but it aint working.. I wonder what PHP function to use to check if a user actually put a file to be uploaded on the server. A validation just in case a user just click the submit button w/out even choosing a file first. I have this code but it aint working... Code: [Select] <?php if(isset($_POST['submit'])) { if(isset($_FILES['uploaded_file'])) { echo "<span class=\"error_validation\">You haven't choose a logo to upload!<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } else { if($_FILES['uploaded_file']["type"] == "image/gif") { $target_path = "logo/"; $target_path = $target_path. basename('matzhee_logo.gif'); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "<span class=\"error_validation\">The Logo has been successfully changed! Refresh the page to see the changed!<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } else { echo "<span class=\"error_validation\">There was an error uploading the logo. Pls. try again.<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } } else { echo "<span class=\"error_validation\">Invalid file format. We are only accepting image file. Pls. try again.<br></span>"; echo "<span class=\"error_validation\">Upload Logo Again? <a href=\"edit_logo.php\">Click Here</a><br></span>"; } } } else { me_redirect_to("edit_logo.php"); } ?> Anyone? thanks I need to pass captured data, basically, a list of email addresses that are being read from a CSV file and (1st) saved to an local database, then sent over to an external source via URL string. I have everything working except - script opens the file, read and validates all emails in the specified column, and saves to local db. ISSUE: after validating then INSERTING the data into local mySQL db, I need to then pass each piece of data to an external source via URL string. Example: www.domain.com?email={$new_email} I was initially think to just add the URL in a header function but, I'm not sure if the HEADER() function the right method to pass all of the data - during the loop - via the URL string. For example, if the CSV file contain 500 emails: Q: how can I continue that loop until the last email read, passing each up to the external source via the URL string? I'm not sure if using the HEADER() function at the end of the script - but within the loop - will interate and send each capture email via that URL string. Can anyone advise a possible solution to this? thanks I work with a large codebase and I have this situation come up fairly often:
the legacy class has large objects such as:
$design->motor->dimensions->a; $design->motor->dimensions->bd; $design->specifications->weight; $design->data->height; //etcWhen I create a new class, that class sometimes operates on the specific data, so say: class MyClass { public function compute($weight, $height, $a) { //stuff } } //and I call this for example as such: (new MyClass())->compute($design->specifications->weight, $design->data->height, $design->motor->dimensions->a);CONS: Potential issue: if design specs change and I need to change things parameters in "compute" function, I need to "re-key" the variables I pass to the function, and adjust things accordinly in MyClass as wel. PROS: only the exact data is being passed, and this data can come from anywhere it is viable, so in effect the function is fairly well separated, I think. Alternative option for me is to pass the entire design object, i.e class MyClass { public function compute(&$design) //can also be done via DI through a setter or constructor. { print $design->specifications->weight; print ($design->data->height + $design->motor->dimensions->a); //stuff } } (new MyClass())->compute($design);PROS: In this case when things change internally in which variables are needed and how things are computed, I only need to change the code in compute function of the class itself. CONS: MyClass now needs to be aware of how $design object is constructed. When it comes to this parameter passing, and Dependency Injection like this in general, does Computer Science advocate a preference on this issue? Do I pass the entire object, or do I pass only the bits and pieces I need? Well, im a n00b for php, and what i need is a php script which will read data from .xml file and write it into .txt file. Can someone help me? Example of .xml file : <?xml version="1.0" encoding="utf-8"?> <tv generator-info-name="NeTXMLTV/1.0.0.0" source-info-url="http://www.net-tv.hr/" source-info-name="NeT TV XMLTV" source-data-url="http://www.net-tv.hr/xmltv/net-pregled-programa-xmltv.xml"> <programme channel="NeT TV" start="20110413063000 +0200" stop="20110413080000 +0200"> <title lang="hr">JUTARNJI EXPRESS</title> <category lang="hr">glazbeno-informativni program</category> <desc lang="hr">Glazbeno informativna emisija sa servisnim informacijama i jutarnjim temperaturama, idealna za jutarnje buđenje uz toplu kavu ili čaj....</desc> </programme> </tv> I need the .txt file to look like this: 201104130630 - 201104130800 JUTARNJI EXPRESS glazbeno-informativni program Glazbeno informativna emisija sa servisnim informacijama i jutarnjim temperaturama, idealna za jutarnje buđenje uz toplu kavu ili čaj.... Can someone please help me? thanks I'm trying to get a simple table to display and am not sure how to make it happen. Table will have just 2 columns. A TIME and an EVENT. What I want to have happen is for the first row to show the TIME and next to that, the EVENT. If a TIME has more than one event going I want the next row to show an empty first cell and then the second event below the first. If I set up the loop the only way I know how (so far) it would also output the TIME value again and again as many times as there were events for that same time. For example what I don't want is: 9:15 Sunday School 9:15 Nursery Available What I do want is: 9:15 Sunday School Nursery Available Thanks. hello, (firts of all, I'm not a php-expert, I just understand the code a little, but I can't write it myself..) I'm using the attached php file (which I found online) to get data out of the attached xml file.(had to rename it to .doc to get it uploaded) What I actually want is the following: From every "User" element showing the attribute "LoginName", and then show under every "LoginName" all the (element)"Contact" and (attributes) "Name" and "Email", right now I just can get the Name, or Email.. example what I would like to have: (using the attached iebo.xml) LoginName: Dirk Contact Name="dirk" Email="dirk@dirk.nl" Contact Name="dirk2" Email="dirk2@dirk.nl" LoginName: test1 Contact Name="test" Email="test@test.nl" Contact Name="test2" Email="test2@test.nl" Thanks for any help in advance Dirk Hi, I need some help, im trying to extract data from a file and display results as text. Example. File: TitanicRomance1990.jpg Output: Movie Name: Titanic Year : 1990
Thank you in Advanced. Hi, I am updating a few parts of my current website. Currently, the website updates user accounts by uploading CSV data reports. I currently use fgetcsv to deal with each row and this is taking forever to deal with the data as this is currently the code for each row. while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $grabinfo = "SELECT * FROM transactions WHERE id = '$data[$i]'"; $grabinforesult = mysql_query($grabinfo) or die(mysql_error()); while($row = mysql_fetch_array($grabinforesult)){ $merchant = $row['merchant']; $username = $row['username']; $datetime = $row['datetime']; $letthem = $row['letthem']; $validate = "SELECT * FROM transactions WHERE merchant = '$merchant' and username = '$username' and (status='pending' or status='success' or status='confirmed') and datetime='$datetime'"; $validator = mysql_query($validate) or die(mysql_error()); if(mysql_num_rows($validator) >= $letthem) { $import="UPDATE transactions SET amount='0.00' WHERE id='$data[$i]' and status ='awaiting'"; mysql_query($import) or die(mysql_error()); }} mysql_query($import) or die(mysql_error()); } fclose($handle); This is performing lots of checks on the csv data and checking it with the system. It checks each row. Is there a quicker way of reading the csv data? There are lots of checks and while loops within the fgetcsv while loop. It can take upto half an hour to process a file with 1000 csv rows. Hope someone could offer some advise. Thanks Hi, I'm quite new to PHP and I'd like to know if there's a way for me to use some PHP solution to get data from another PHP file instead of used AJAX. My intention is to have some kind of a loop in one PHP file that'll have a variable that gets the returned data from a different PHP file on every iteration and does something with it. Would be simple enough to do it with Ajax but I can't use it in this instance. Any thoughts? I'm trying to write to a xml file from my database. Have it writing to the file ok with a simple string: -------- $handle = fopen("test.xml", "w");//erase file first $filename = 'test.xml'; $somecontent = "Add this text to the file\n"; // make sure the file exists and is writable first. if (is_writable($filename)) { // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> -------- So how would i go about adding a while loop to it to so it writes all the rows from my database. I was going to manually write the xml tags in. For example: <newsitem id=['id']> <title>['heading']</title> <content>['description']</content> <date>['date']</date> </newsitem> obviously with the php tags... just not sure how to do this loop within the fwrite section. I tried just the normal : while ($row = mysql_fetch_array($result)) { print " <tr>"; print " <td>" . $row["id"] . "</td>"; print " <td>" . $row["date"]. "</td>"; print " <td>" . $row["heading"]. "</td>"; print " <td>" . $row["content"]. "</td>"; print " </tr>"; } print "</table>"; } but it wasnt writing it into the file, not sure how i would reference that loop code to the $somecontent variable. is there a php solution that will take the raw data from one file and paste it into another text file? I have a master file and a download file that always starts at quarter past midnight . this data needs to be pasted into the master file, in the correct place , possibly overlapping and replacing data that already exists. the length of the download file will vary but will always start at 00. 15 the two files are www.maidenerleghweather.com/download.txt and also www.maidenerleghweather.com/master.txt any help appreciated . hello, I need xml file as playlist.xml and i want to retrive data from my mysql table. I have the following code as i am trying to use php code inside playlist.xml file. Code: [Select] <?xml version="1.0" encoding="utf-8"?> <xml> <?php $dbhost='localhost'; $dbuser='pavel'; $dbpass='pavel123'; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db("amarmusic"); $sql=("select *from bband where artist='Meghdol' and album='Drohe Montre Valobasha';"); $res = mysql_query($sql); while ($result = mysql_fetch_array($res)){ ?> <track> <path> <? $result['link']?></path> <title><? $result['title']?></title> </track> <? } ?> </xml> but unfortunately its not working. any1 have any idea how to fix it? please help me. |