Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

xtiancjs's Achievements


Member (2/5)



  1. 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>
  2. 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.
  3. 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.
  4. Ouch ! my bad - forgot to add "[]" to the $session variable. so it should read: foreach($_POST['firsname'] as $value) { $_SESSION['firstname'][] = $value ; }
  5. 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?
  6. HI, am having some major trouble with this one. I have set up a user login system. The user id # is stored in a mysql DB. So far so good. The user has been given a "one use only" user #. When the user logs out, I want to be able to delete that particular users id # from the DB. This I have failed to do. Please help!!
  • 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.