我正试图回过一次习惯问询,但有时问询表相同。 例如。 我的产出守则目前就是这样......
//Query one returns each instance of an object. There are two of the first, one of the second.
13775
13775
66777
//Query two returns each bit of information against the first object.
// As you can see its loading the first too twice because of the query above being the same...
SID=13775 TOKEN=b8r5x6w53d6cahw
SID=13775 TOKEN=p5ugbeg68b4qixy
SID=13775 TOKEN=b8r5x6w53d6cahw
SID=13775 TOKEN=p5ugbeg68b4qixy
SID=66777 TOKEN=4c85zznh955gjsc
我的法典如下所示。
页: 1
$query = "SELECT * FROM lime_all_tokens WHERE fname= ".$fname." AND lname = ".$lname." ";
//execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
$sid = array();
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
$i = 0;
while($row = mysql_fetch_row($result)) {
//Shows the SID s
echo $row[5]."<br />";
//Add into the DB in order...
$sid[] = $row[5];
$i++;
}
}
// free result set memory
mysql_free_result($result);
for ($j = 0; $j < $i; $j++) {
$querytokens = "SELECT * FROM lime_tokens_".$sid[$j]." WHERE firstname= ".$fname." AND lastname = ".$lname." ";
echo $tokens[$j]."<br />";
//execute query
$resulttokens = mysql_query($querytokens) or die ("Error in query: $querytokens. ".mysql_error());
// see if any rows were returned
//print_r(mysql_fetch_row($resulttokens));
while($rowtokens = mysql_fetch_row($resulttokens)) {
//Display our token
echo "SID=".$sid[$j]." TOKEN=".$rowtokens[5]."<br />";
$displayonce = false;
}
}
echo "<br /><br /><h2>There are a total of ".$i." calls availible!</h2>";
// free result set memory
mysql_free_result($resulttokens);
// close connection
mysql_close($connection);
怎样才能使数据适当退回? i.e
13775
13775
66777
SID=13775 TOKEN=b8r5x6w53d6cahw
SID=13775 TOKEN=p5ugbeg68b4qixy
SID=66777 TOKEN=4c85zznh955gjsc