Jump to content

xtiancjs

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Posts posted by xtiancjs

  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. 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());

  3. 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 />' ;
    } ?>
    
    

     

  4. 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. 

  5. 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

     

  6. 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>

  7. 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.

     

     

  8. 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?

  9. Thanks for the reply

     

    My second query would be something along the lines of

     

    SELECT first_name, last_name FROM artists WHERE CONCAT(first_name,last_name) ='$name_search'  or something along those lines.

     

    I originally tried a few queries trying to get results from both tables all similar to:

     

    SELECT images.artist, artists.first_name, artists.last_name FROM images, artists WHERE images.caption LIKE '%$keyword%' OR images.piece_name LIKE '%$keyword%' OR images.show_title LIKE '%$keyword%'  AND CONCAT(artists.first_name,artists.last_name) = images.artist GROUP BY images.artist

     

    the server this is on is using mysql version 3.23.58 (I obviously wish they would update soon)

     

    Does this help?

  10. Hi,

    I have an array that has x number of values. I want to run a sql statement x number of times using the next array value each time.

    Basically I have a query that displays results based on a search. The result of the search is a list of names, the trouble is for reasons beyond my control the names are in a single db field as "FirstLast". I want to take this value and match it up to another table that has the first and last names in separate fields. So far I have extracted the results from the first query using a while loop, the resulting array is called $name_search :

     

    mysql_select_db($database_nancy, $nancy);

    $query_search = "SELECT artist FROM images WHERE caption LIKE '%$keyword%' OR piece_name LIKE '%$keyword%' OR show_title LIKE '%$keyword%' GROUP BY artist";

    $search = mysql_query($query_search, $nancy) or die(mysql_error());

    $totalRows_search = mysql_num_rows($search);

    $name_search = array();

    while(list($artist) = mysql_fetch_row($search)) {

    $name_search[] = $artist;

    }

     

    I now want to take the values of the $name_search array and run a SELECT statement on table2 for each value and display the results. Could a foreach loop handle that ?

  11. Hi , just say I have a query that goes "SELECT item_name FROM products WHERE products.drink = 'juice'" . If I get back 12 results from this query I can make a list using a simple loop, that is fine . If I click on one of these list items I want to go to a detail page, again I can do this no probs. How do I carry over to the detail page the number that the item appeared in the original list, for example if a result was "orange" and it was the 5th one in the list, how do I carry over the number 5 to the detail page?

     

    thanks

  12. Hi, Am on the right track I think , What I want to do is create a next link that will cycle through all the values of an array. In this case the values are images and I would like to load them into their own page or <div> on the click of NEXT . so far I have managed to create the array and load the first image correctly.

    I have deleted any duplicate and empty array values as well.After an initial click the next link is only cycling through the lowest 2 values and not all values. Does this have something to do with the array resorting itself on each page load? Not too sure . Here is the code I have so far:

     

    <?php require_once('../Connections/nancy.php'); ?>
    <?php
    $iid = $_GET['imageID'];
    $image = $_GET['imagenameID'];
    $artist = $_GET['artistID'];
    $dir = "../artist_images/$artist/";
    $dh = opendir($dir);
    while (false !== ($file = readdir($dh))) {
    $files[] = $file;
    }
    $nfiles = array_unique($files);
    foreach($nfiles as $key => $value) {
      if($value == "..") {
    unset($nfiles[$key]);
      } elseif($value == ".") {
        unset($nfiles[$key]);
      }elseif($value == "") {
        unset($nfiles[$key]);
      }
    }
    $new_array = array_values($nfiles);
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    
    </head>
    
    <body>
    <div id="image"> <img src="<?php  echo "$dir/$image"; ?>" > </div>
    <?php echo "$dir"; ?>
    <?php  
              
    	   print_r($nfiles);//to see values
    
    	   $next_image = next($nfiles);  ?>
    	   <a href="image_detail.php?artistID=<?php echo "$artist"; ?>&imagenameID=<?php  echo "$next_page"; ?>">next</a>
    
    </body>
    </html>

     

    Thanks for any help!!

  13. [!--quoteo(post=371841:date=May 6 2006, 01:27 PM:name=freakus_maximus)--][div class=\'quotetop\']QUOTE(freakus_maximus @ May 6 2006, 01:27 PM) [snapback]371841[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    What you want is possible, sure, but not via 2 inserts. You would end up overwriting what you had with the 2 insert.

    You should just put both values into 1 variable and submit that variable to be inserted.

    So, on the php page that process your insert, after you get the variables from your form.
    [code]
    $vartoinsert = $dropdownvalue.$textvalue

    //or if you want a space in between the two do this

    $vartoinsert = $dropdownvalue . ' ' . $textvalue
    [/code]

    You would insert the $vartoinsert into column_a

    Hope that helps.
    [/quote]


    Freakus, thanks for the reply, will give it a shot
    xtian
  14. Hi, just wondering if it is possible to insert into the same db field from 2 different text input areas in the same form?
    I have a a drop down menu which inserts the info into column_a on the db , on the same form I have a text field that I want to also insert the info into column_a,


    Xtian
  15. Hi This is what I had:


    mysql_select_db($database_broker, $broker);
    $query_brokers = "SELECT * FROM brokers ORDER BY '$valrate1' DESC";
    $query_limit_brokers = sprintf("%s LIMIT %d, %d", $query_brokers, $startRow_brokers, $maxRows_brokers);
    $brokers = mysql_query($query_limit_brokers, $broker) or die(mysql_error());
    $row_brokers = mysql_fetch_assoc($brokers);
    $valrate1 = (($row_brokers['broker_rating']/$row_brokers['broker_num_votes'])+
    ($row_brokers['broker_rating_two']/$row_brokers['broker_num_votes_two'])+ ($row_brokers['broker_rating_three']/$row_brokers['broker_num_votes_three']))/3;
×
×
  • 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.