Page 1 of 1

anyone know how to put this in a while loop

Posted: Sat Jul 07, 2007 9:05 am
by divx
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


anyone got an idea how to complete the following while loop. I want to set a database column (LT_URL) to a sting ($ltURLarray[i]), 
but 1st i want to check if it already exist in the db, if it does exist, then I want to test the next sting exist in the db, if it doesnt set LT_URL to $ltURLarray[i] on the i'th attempt.

Code: Select all

$ltURLarray[0] = 'string0';
$ltURLarray[1] = 'string1'; //.......
$ltURLarray[100] = 'string100';

// some how put the follwing in a while loop while i<100:
i = 0;
URLdata = mysql_query("SELECT LT_URL FROM lt_Users WHERE LT_URL = '$ltURLarray[i]' LIMIT 1")or die(mysql_error()); 
if (!mysql_num_rows($URLdata)){
	$ltURL =$ltURLa[0];
	}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Jul 07, 2007 9:22 am
by feyd
Why must it be a while loop?

You may, possibly, want to use the IN construct found in MySQL.

Posted: Sat Jul 07, 2007 9:25 am
by divx
feyd wrote:Why must it be a while loop?

You may, possibly, want to use the IN construct found in MySQL.
it doesnt have to be a while loop, Ill have a look at IN

Posted: Sat Jul 07, 2007 10:23 am
by s.dot
may also want to have a look at the php function implode()