Jump to content

Recommended Posts

I have this function

 

	  	function GetIMfromDatabase($StartTimeStamp,$EndTimeStamp){
	$sql=mysql_query("SELECT * 
						FROM msnconvosations WHERE `StartTime` BETWEEN '".addslashes($StartTimeStamp)."' AND '".addslashes($EndTimeStamp)."'");
   		while ($text=mysql_fetch_array($sql)){
      		return $text;

}
}

 

and i am calling it like

 

$info = GetIMfromDatabase($StartTimestamp,$EndTimestamp);

 

Now it should return two sets of information but its only return one set. Why???

Link to comment
https://forums.phpfreaks.com/topic/145977-solved-return-db-results/
Share on other sites

Because return will break outta that loop and return that value.

 

You need to do something like:

function GetIMfromDatabase($StartTimeStamp,$EndTimeStamp){
$sql=mysql_query("SELECT * 
						FROM msnconvosations WHERE `StartTime` BETWEEN '".addslashes($StartTimeStamp)."' AND '".addslashes($EndTimeStamp)."'");
   	while ($text=mysql_fetch_array($sql)){
	$array[] = $text;

}
return $array;
}

cool, that generate an array

 

Array ( [0] => Array ( [0] => 2 [EnterID] => 2 [1] => 1 [ComputerID] => 1 [2] => sfdsfsd [From] => sfdsfsd [3] => sdfdsfds [To] => sdfdsfds [4] => 1235063869 [startTime] => 1235063869 [5] => 1235063869 [EndTime] => 1235063869 [6] => fgfgfdgdfgdf [Convosation] => fgfgfdgdfgdf ) [1] => Array ( [0] => 3 [EnterID] => 3 [1] => 1 [ComputerID] => 1 [2] => sdfsdfsdf [From] => sdfsdfsdf [3] => sdfsdfsdfd [To] => sdfsdfsdfd [4] => 1235063869 [startTime] => 1235063869 [5] => 1235063869 [EndTime] => 1235063869 [6] => eferertretet [Convosation] => eferertretet ) )

 

how will i get it all seperated out i.e

computerID

From

To

StartTime

EndTime

Convosation

i am trying this

 

$count = count($info);
if(isset($info))
{
for ($i=1; $i<=$count; $i++)
{
echo "Information for the Date" .$d."/".$m."/".$y;
echo "<br />"; 
echo $info[$i]['ComputerID'];
echo "<br />";
echo $info[$i]['From'];
echo "<br />";
echo $info[$i]['To'];
echo "<br />";
echo date("F j, Y, g:i a",$info[$i]['StartTime']);
echo "<br />";
echo date("F j, Y, g:i a",$info[$i]['EndTime']);
echo "<br />";
echo $info[$i]['Convosation'];
}
}

 

but getting nothing anyone??

cool, that generate an array

 

Array ( [0] => Array ( [0] => 2 [EnterID] => 2 [1] => 1 [ComputerID] => 1 [2] => sfdsfsd [From] => sfdsfsd [3] => sdfdsfds [To] => sdfdsfds [4] => 1235063869 [startTime] => 1235063869 [5] => 1235063869 [EndTime] => 1235063869 [6] => fgfgfdgdfgdf [Convosation] => fgfgfdgdfgdf ) [1] => Array ( [0] => 3 [EnterID] => 3 [1] => 1 [ComputerID] => 1 [2] => sdfsdfsdf [From] => sdfsdfsdf [3] => sdfsdfsdfd [To] => sdfsdfsdfd [4] => 1235063869 [startTime] => 1235063869 [5] => 1235063869 [EndTime] => 1235063869 [6] => eferertretet [Convosation] => eferertretet ) )

 

thats a bit hard to read, so do this:

echo '<pre>'; print_r($info); echo '</pre>';

It'll make it easier to read.

 

What you're currently doing should work, but let's see if there is something else.

it gave

 

Array

(

    [0] => Array

        (

            [0] => 1

            [EnterID] => 1

            [1] => 1

            [ComputerID] => 1

            [2] => ad_plowman@hotmail.com

            [From] => ad_plowman@hotmail.com

            [3] => dingus_76@hotmail.com

            [To] => dingus_76@hotmail.com

            [4] => 1235399556

            [startTime] => 1235399556

            [5] => 1235043709

            [EndTime] => 1235043709

            [6] => You smell

            [Convosation] => You smell

        )

 

)

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.