John, Dan & All,

Thanks for your response, perhaps if I tell you more of the story then it'll
make more sense. I'm afraid I seem to have an ability for asking cryptic

Below is the code I'm using, it is meant to check for a list of between 10
and 50 words in a table then return the key of the words found, for the
words not in the table they should be added to the table.

It seems to work fine, but in a effort to make the code more efficient I
realised that at present I'm walking through a lot of the recordset for each
keyword. But that the majority of the recordset would be in the same order
as the keywords. So if I can add a little extra code that says if the next
record in the recordset is not the word I'm trying to find then walk through
the recordset, if you reach the end then start at the beginning and go
down-to the initial row. This should confirm that the word is not in the
recordset and so needs to be added, but leave the recordset in the correct
place to check the next word.

However to do this I thought initialy I would need to identify the row the
recordset was presently at. However now I understand I need to push the
recordset into an array then use this array to loop through finding the
key's and the words that need to be added. However saying it and coding it
seem to be two completely different things, can anyone help me getting
started? Hope this makes some sense? If you have any other comments on the
code to improve it or good coding practice I would appreciate your comments
as I'm still new to this.




#--create select statement for getting keywords from table
$fndWrds = '';
foreach($kywrd as $val) {
 $fndWrds .= "wrd = '$val' OR ";

#-- add test word to get a result regardless
$fndWrds .= "wrd = 'test'";

#-- get present keywords from db
$dbKy = mysql_query("SELECT ky, wrd FROM ".$site_no."kywrdInd WHERE

#--create kywrd index array for index to be used in update value list
$indx = array();

#--create update value lists to later add record into lookup table
$vlst = '';

foreach($kywrd as $key => $val) {
 $fnd = 0;
 While ($kyRw = mysql_fetch_array($dbKy)) {
  if($kyRw['wrd'] == $val) {
   $fnd = 1;
   $indx[$key] = $kyRw['ky'];
   break 1;
 #-- reset pointer of db array back to begining
 mysql_data_seek($dbKy, 0);

 #-- if not in db then add word to db then set index
 if($fnd == 0) {
  if(! mysql_query("INSERT INTO ".$site_no."kywrdInd (wrd) values
('".$val."');")) echo 'Word not added';
  $indx[$key] = mysql_insert_id();

 #-- check to see that each word has an index value
 if($indx[$key]) {
  #--create value list for update into lookup table
  $vlst .= "($compID," . $indx[$key] . "," . $scr[$key] . "), ";
 } else {
  echo 'no index set for keyword, word = '.$val.' index = '.$key.'<br>';

----- Original Message -----
From: "John Holmes" <[EMAIL PROTECTED]>
Sent: Friday, June 14, 2002 6:42 PM
Subject: RE: [PHP] row pointer

> Keep track of it yourself as you loop through the data. Maybe if you
> explained what you need "overall" then we could suggest a method...
> ---John Holmes...
> > -----Original Message-----
> > From: Zac Hillier [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, June 14, 2002 3:59 AM
> > Subject: [PHP] row pointer
> >
> > Hi
> >
> > I'm looking for a php function that will return the position of the
> > pointer
> > in a mysql recordset.
> >
> > I found mysql_data_seek, but this appears to only move the pointer, I
> need
> > to get the equivalent row number for the pointer position before
> moving
> > it,
> > then return to the same position.
> >
> > Can anyone help?
> >
> > Thanks
> >
> > Zac
> >
> >
> > --
> > PHP General Mailing List (
> > To unsubscribe, visit:
> --
> PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to