Jump to content

xtiancjs

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xtiancjs's Achievements

Member

Member (2/5)

0

Reputation

  1. A brief overview of how I would start this. Seems like there will be multiple calls to a base url with some changing parameters. looking here: http://www.loc.gov/standards/sru/simple.html points 2, 3, and 5 seem like the way to start. So essentially you are making an initial call to give you the number of records, then the same call a bunch of times to get the next set based upon your parameters in the url. I would create a class file that deals with all this in an oop fashion. You would have a method that sends the requests, I would use curl, and a method that deals with parsing the xml - simpleXml(for the simple xml look into parsing children of namespaces in this case "zs" - simple xml can definitely parse these results just have to experiment with the correct syntax and combo of children() etc.). No need to actually write data to a file or DB until you really need to at the end for a single record.
  2. also, if you are just getting the xml from a remote address and you wish to just write the raw contents to a file, you don't need simple xml till later. Simple xml is for parsing and writing xml. You could also get the page contents using curl.
  3. Also, I highly discourage doing a string replace on the ":" in your returned xml. The ":" denotes the namespaces in the xml string. You will run into troubles trying to parse your file later on.
  4. Just worked on something similar, try this : $url = file_get_contents('http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&startRecord=2&maximumRecords=5'); $xml = new SimpleXMLElement($url) ; //file put contents - same as fopen, wrote and close //need to output "asXML" - simple xml returns an object based upon the raw xml file_put_contents(dirname(__FILE__)."/loc.xml", $xml->asXML());
  5. I had to do something similar in wordpress using the array_chunk() function http://php.net/manual/en/function.array-chunk.php This may give you some ideas - basically you are splitting your $show array into 3 new arrays and printing each in their own column //empty arrays $firstn = array(); $lastn = array(); $lastn2 = array(); $link = array(); //populate the above arrays $tags = get_tags(); foreach ($tags as $tag ) { $piece = $tag->slug; $pieces = explode("-",$piece); array_push($firstn,$pieces[0]); array_push($lastn,$pieces[1]); array_push($lastn2,$pieces[2]); array_push($link, get_tag_link ($tag->term_id)); } //extract values of arrays and sort alpha by last name $firstname = array_values($firstn); $lastname = array_values($lastn); asort($lastname); $lastname2 = array_values($lastn2); $taglinks = array_values($link); //new array that is combination of first, last and link $all = array(); //populate $all foreach($lastname as $key=>$value) { $all[$value][0] = $value; $all[$value][1] = $firstname[$key]; $all[$value][2] = $taglinks[$key]; $all[$value][3] = $lastname2[$key]; //count number of names $number = count($all); // get number for chunk value $chunk_value = round($number / 3) ; } //array of 3 columns $col = array(); //split into 3 $col = array_chunk($all, $chunk_value, true); //column 1 values $column1 = array_values($col[0]); //colum 2 values $column2 = array_values($col[1]); //column 3 values $column3 = array_values($col[2]); //display content ?> <?php foreach ($column1 as $key=>$value) { echo '<a href="'. $value[2] .'" rel="tag">'. $value[1].' '.$value[0].' '.$value[3].'</a><br />' ; } ?><?php foreach ($column2 as $key=>$value) { echo '<a href="'. $value[2] .'" rel="tag">'. $value[1].' '.$value[0].' '.$value[3].'</a><br />' ; } ?> <?php foreach ($column3 as $key=>$value) { echo '<a href="'. $value[2] .'" rel="tag">'. $value[1].' '.$value[0].' '.$value[3].'</a><br />' ; } ?>
  6. Email clients can't execute scripts server or client side - this is a big security issue. I would use your php/mysql script in conjunction with the phpmailer class. So for example your have a php script named "send.php" - The first part of the script gets the date and hence the DB info and outputs the correct HTML to a file on your server. The second part of the script uses the phpMailer class to send out the HTML file created earlier. So when you go to http://somehost.com/send.php in your browser the correct html is sent to your list.
  7. I don't see a <form> tag in your code that points to the php script
  8. Hi, Anyone come across this? Doing some work on a project that uses a MVC pattern. There is a "_core" directory , and all the files have "jument" as a prefix. i.e. - jument.core.view.php have done a search can't find anything. Not having any troubles just wonder if there is some kind of documentation or site etc etc
  9. This was my eventual solution to order tags in wordpress by the second word - in this case last name, and then split that into 3 columns - that seems to be working. There is prob a more concise way to write this. Thanks for the responses. <h2><?php //empty arrays $firstn = array(); $lastn = array(); $lastn2 = array(); $link = array(); //populate the above arrays $tags = get_tags(); foreach ($tags as $tag ) { $piece = $tag->slug; $pieces = explode("-",$piece); array_push($firstn,$pieces[0]); array_push($lastn,$pieces[1]); array_push($lastn2,$pieces[2]); array_push($link, get_tag_link ($tag->term_id)); } //extract values of arrays and sort alpha by last name $firstname = array_values($firstn); $lastname = array_values($lastn); asort($lastname); $lastname2 = array_values($lastn2); $taglinks = array_values($link); //new array that is combination of first, last and link $all = array(); //populate $all foreach($lastname as $key=>$value) { $all[$value][0] = $value; $all[$value][1] = $firstname[$key]; $all[$value][2] = $taglinks[$key]; $all[$value][3] = $lastname2[$key]; //count number of names $number = count($all); // get number for chunk value $chunk_value = round($number / 3) ; } //array of 3 columns $col = array(); //split into 3 $col = array_chunk($all, $chunk_value, true); //column 1 values $column1 = array_values($col[0]); //colum 2 values $column2 = array_values($col[1]); //column 3 values $column3 = array_values($col[2]); //display content ?> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td valign="top"><?php foreach ($column1 as $key=>$value) { echo '<a href="'. $value[2] .'" rel="tag">'. $value[1].' '.$value[0].' '.$value[3].'</a><br />' ; } ?></td><td valign="top"><?php foreach ($column2 as $key=>$value) { echo '<a href="'. $value[2] .'" rel="tag">'. $value[1].' '.$value[0].' '.$value[3].'</a><br />' ; } ?></td> <td valign="top"><?php foreach ($column3 as $key=>$value) { echo '<a href="'. $value[2] .'" rel="tag">'. $value[1].' '.$value[0].' '.$value[3].'</a><br />' ; } ?></td></tr> </table> </h2>
  10. Thanks guys, Unfortunately i have no control over how the original names array is created. From the code posted i think i can work it out - will post resulting code here as a reply. Thanks again.
  11. Hi , I have an array of values that contain a firstname and lastname. $names = array('John Smith','Fred Johnson','Mark Williams'); How would i display them so they are ordered alpha by the last name? I was thinking i could split each value into a $key=>$value pair and order the result by the $value. Not sure how (or if this is the right way) to go about this.
  12. Ouch ! my bad - forgot to add "[]" to the $session variable. so it should read: foreach($_POST['firsname'] as $value) { $_SESSION['firstname'][] = $value ; }
  13. Hi , I have a form which adds names to a list 3 at a time. I have it adding the first lot of 3 no problem, when I try and resubmit the form the original 3 names are replaced by the later 3. I am trying to have them add to the original so a larger list is formed. My HTML: <input id="firstname" type="text" name="firstname[]" size="20"><br> <input id="firstname" type="text" name="firstname[]" size="20"><br> <input id="firstname" type="text" name="firstname[]" size="20"> My PHP code: foreach($_POST['firsname'] as $value) { $_SESSION['firstname'] = $value ; } Any ideas?
  14. The final query I used which is giving me the results I need : SELECT * FROM artists, images WHERE artists.id = images.artist_id AND ((images.caption LIKE '%$keyword%') || (images.piece_name LIKE '%$keyword%') || (images.show_title LIKE '%$keyword%')) GROUP BY artists.last_name Thanks again mjdamato for all your help
  15. Thanks for all your help, I did basically the same thing via the terminal and adjusted the form that deals with adding images to the images table, so from now on there will be a corresponding artist_id number that matches the first_name last name entry in the artists table. Will now test that earlier join query you suggested. Thanks again
×
×
  • 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.