Jump to content

Archived

This topic is now archived and is closed to further replies.

onlyican

Parsing around the world

Recommended Posts

Hey

This is a mix of php, MySQL, and Javascript

I have downloaded a chat room
They have a function that allowes you to add links to the username in the chat room

The example they give is something like this

[code]
pfcClient.prototype.updateNickList = function(lst)
{
  this.nicklist = lst;
  var nicks  = lst;
  var nickdiv = this.el_online;
  var ul = document.createElement('ul');
  for (var i=0; i<nicks.length; i++)
  {
    var li = document.createElement('li');
    var a = document.createElement('a');



 
    a.setAttribute('href','http://www.google.com/search?q='+nicks[i]);
    a.setAttribute('target','_blank');
    a.setAttribute('class', '<?php echo $prefix; ?>nickmarker <?php echo $prefix; ?>nick_'+ hex_md5(nicks[i]));
    var txt = document.createTextNode(nicks[i]);
    a.appendChild(txt);
    li.appendChild(a);
    ul.appendChild(li);
  }
  var fc = nickdiv.firstChild;
  if (fc)
    nickdiv.replaceChild(ul,fc);
  else
    nickdiv.appendChild(ul,fc);
  this.colorizeNicks(nickdiv);
}
[/code]

This is Javascript a guess

THe array "nicks" is what is holding the usernames,
I dont know Javascript that well
But I am guessing it loops through the usernames, from the for loop
(Dont they have foreach in javascript)

Anyway

What I want to do is grab the username
Run a MySQL query to select the id
Maybe store the results in array called
id_nicks
Then run my link
with id_nicks there, not google

What I dont know how to do is
parse the array nicks into php

then parse the php array back into the javascript

unless I run a query per username
which I dont want to do

Any suggestions, comments ???

Share this post


Link to post
Share on other sites

×

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.