I've an interlinking script that pulls domains from a MySQL dB by ID and then creates random links using the links associated with that ID. I just need some code that will compare the ID to a list of ID's. If the ID matches it ignores or skips that ID and it isn't written to the $domain variable This is the domain selection code while($z < $nb){ //select Random domain $query="SELECT domain_id,domain FROM domain ORDER BY rand() Limit 1"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $predomain_id=mysql_result($result,$i,"domain_id"); $domain_id = $predomain_id; $predomain=mysql_result($result,$i,"domain"); $domain = $predomain; $i++; } Code (markup): Paypal or egold. Payment after successful test.
this code is really ineffecient and does not seem to do much of anything useful. PM me with more details about the overall scope of what you're doing and i'll give you a hand.
It's pretty hard to give you much help without seeing the code in context (as the previous poster said). However, one obvious error was the use of mysql_numrows, it is in fact mysql_num_rows, so this could have caused your entire script to function incorrectly. Also, by having $i = 0 within the while loop, it means it will get reset to 0 every time, making the $i++ null and void. It needs to be defined before the loop begins. Try this, I've cleaned it up a bit. $i=0; while($z < $nb) { // Select random domain $query = "SELECT domain_id, domain FROM domain ORDER BY RAND() LIMIT 1"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($i < $num) { $predomain_id = mysql_result($result,$i,"domain_id"); $domain_id = $predomain_id; $predomain = mysql_result($result,$i,"domain"); $domain = $predomain; $i++; } } PHP: I don't use the mysql_result function myself, so I'm hoping that is not the part that is functioning incorrectly.
yeah, i agree with the two posters above, although i'm pretty sure that what you wanted to do was easy, the code itself is hard to understand, having it in context would do wonders
Thanks guys, for those that contacted via PM or here. Unfortunately none of the suggested methods work. If anyone is up for writing a custom interlinking script that can pull data selectively from a dB, PM with any queries and an estimated cost. cheers