| px | top | add code | search | signup | login | help |
<?
//mysql_subquery
//copyright 1999 avi bryant, all rights reserved
//feel free to use this and modify it as you see fit
function sub($result)
{
if($result == 0)
return "()";
else
{
$row = mysql_fetch_row($result);
$strResult = "( $row[0]";
while($row = mysql_fetch_row($result))
$strResult = "$strResult , $row[0]";
$strResult = "$strResult )";
return $strResult;
}
}
function mysql_subquery($query)
{
$substart = strpos($query, "(");
if($substart != false)
{
$subend = strrpos($query, ")");
$before = substr($query, 0, $substart);
$after = substr($query, $subend+1, -1);
$subquery = substr($query, $substart+1, $subend-$substart-1);
$subresult = mysql_subquery($subquery);
$subtext = sub($subresult);
return mysql_query($before . $subtext . $after);
}
else return mysql_query($query);
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.