Jump to content

Recommended Posts

Sure it'll work--if you code it right. 

 

Try posting your code.

 

In the meantime, I'll give you an example.

 

$test = 1;
while ($test){
    echo "Line" . $test . ":  ";
    $c = 1;
    while($c){
       echo $c . "-";
       if ($c == 10){
          $c = false;
          echo "<br>";
       }
    }
    if ($test == 10){$test = 0;} 
}

 

I haven't tested this to see if there are any typos (hopefully not) but you should be able to get the gist of it.

 

It should output the following:

 

Line1:  1-2-3-4-5-6-7-8-9-10-

Line2:  1-2-3-4-5-6-7-8-9-10-

Line3:  1-2-3-4-5-6-7-8-9-10-

Line4:  1-2-3-4-5-6-7-8-9-10-

Line5:  1-2-3-4-5-6-7-8-9-10-

Line6:  1-2-3-4-5-6-7-8-9-10-

Line7:  1-2-3-4-5-6-7-8-9-10-

Line8:  1-2-3-4-5-6-7-8-9-10-

Line9:  1-2-3-4-5-6-7-8-9-10-

Line10:  1-2-3-4-5-6-7-8-9-10-

ok what i'm trying to do is this:

 

     while ($searchqueryrow = mysql_fetch_array($searchquery)) {
$filelink = formatSearch($searchqueryrow['filelink'], $trimmedsearchterm);
$filetotalmirrors = $searchqueryrow['filetotalmirrors'];
$filegeneraltype = $searchqueryrow['filegeneraltype_en'];
$filespecifictype = $searchqueryrow['filespecifictype_en'];
$filegeneraltypekey = $searchqueryrow['filegeneraltype_en'];
$filespecifictypekey = $searchqueryrow['filespecifictype_en'];
$filedateadded = $searchqueryrow['filedateadded'];
$filesubmitter = $searchqueryrow['filesubmitter'];
$fileid = $searchqueryrow['fileid'];

$keywordtablequery = mysql_query("SELECT * FROM keywords WHERE keyword='$keyword'");
//--------------------------------------------------------------begin keyword table shit
while ($keywordtablerow = mysql_fetch_array($keywordtablequery))
{
$keywordtablequery = mysql_query("SELECT * FROM keywords WHERE keyword='$keyword'");
$keywordtablerow = mysql_fetch_array($keywordtablequery);
$keywordfileid = $keywordtablerow['keywordfileid'];
$matchedkeyword = $keywordtablerow['keyword'];
echo $matchedkeyword;
$keywordip = $keywordtablerow['keywordip'];
$keywordentryid = $keywordtablerow['keywordentryid'];
$keywordlink = <<<KEYWORDLINK
<a href="searchresults.php?searchterm=$keyword">$keyword</a>
KEYWORDLINK;


if ($keywordfileid == $fileid && $keywordip == $userip && $matchedkeyword == $keyword)
{
$updatekeywordtablequery = mysql_query("UPDATE `keywords` SET `keywordtimestamp`='$datetime', `keywordip`='$userip', `keyworduserid`='$userid' WHERE `keywordentryid`='$keywordentryid'");
echo "KEYWORD TABLE WAS UPDATED ONLY should be no new ids if same search";
}
else
{
$insertkeywordtablequery = "INSERT INTO `keywords` ( `keywordfileid`, `keyword`, `keywordspecifictype`, `keywordgeneraltype`, `keywordip`, `keyworduserid`, `keywordtimestamp`, `keywordfilelink`, `keywordlink` )
VALUES ( '$fileid','$keyword','$filespecifictypekey','$filegeneraltypekey','$userip','$userid','$datetime', '$filelink', '$keywordlink' )";
$runinsertkeywordtablequery = mysql_query($insertkeywordtablequery);
echo "KEYWORD TABLE WAS INSERTED ONLY";
}
}

//-----------------------------------------------------------------------------------------------end keyword table shit

$searchtableinside = <<<EOT
        <tr>
          <td class="nombre">$filelink</td>
          <td class="nombre">$filetotalmirrors</td>
          <td class="fecha">$filedateadded</td>
          <td class="descargas">$filespecifictype</td>
          <td class="descargas">$filesubmitter</td>
        </tr>
EOT;
echo $searchtableinside;
}
//end while function and display searchtableinside
     break;
}
//end switch statement

 

thats the real code i'm using

 

here is the watered down version:

 

while ($searchqueryrow = mysql_fetch_array($searchquery))
{
i know $searchqueryrow will have 5 rows so all this shit should repeat 5 times

while ($keywordtablerow = mysql_fetch_array($keywordtablequery))
{
I know $keywordtablerow has 2 rows so this should repeat 10 times

}
}

the result however is $searchqueryrow shit does loop 5 times, but $keywordtablerow doesn't loop at all

the real code i'm using is pasted in the first code post

You are duplicating the query inside the loop that is processing the query

 

$keywordtablequery = mysql_query("SELECT * FROM keywords WHERE keyword='$keyword'");

//--------------------------------------------------------------begin keyword table shit

while ($keywordtablerow = mysql_fetch_array($keywordtablequery))

{

$keywordtablequery = mysql_query("SELECT * FROM keywords WHERE keyword='$keyword'");

$keywordtablerow = mysql_fetch_array($keywordtablequery);

$keywordfileid = $keywordtablerow['keywordfileid'];

...

...

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.