Call from my index.php to function get_data($curr_date)
goes from here
case "events" :
$curr_date = $_POST['current_date'];
if ( $eid = get_data($curr_date) )
{
$result = array( "success"=>true,
"eid"=>$eid);
$json_output = json_encode( $result );
echo $json_output;
}
else
echo FAIL;
break;
enter code here
This is my function which returns the result
function get_data($curr_date)
{
$events_list = mysql_query( "SELECT eid, display_date, word_of_the_day, word_of_the_day_meaning, thought_of_the_day,
crazyFact_of_the_day, joke_of_the_day FROM eventsoftheday WHERE display_date = '$curr_date' ");
// get mysql result cursor
if( mysql_num_rows( $events_list ) > 0 ) // check if the query returned any records
{
$mysql_record = mysql_fetch_array( $events_list ); // parse mysql result cursor
$events = array();
$events['e_id'] = $mysql_record['eid'];
$events['edisplay_date'] = $mysql_record['display_date'];
$events['eword_of_the_day'] = $mysql_record['word_of_the_day'];
$events['eword_of_the_day_meaning'] = $mysql_record['word_of_the_day_meaning'];
$events['ethought_of_the_day'] = $mysql_record['thought_of_the_day'];
$events['ecrazyFact_of_the_day'] = $mysql_record['crazyFact_of_the_day'];
$events['ejoke_of_the_day'] = $mysql_record['joke_of_the_day'];
return $events; // return events
}
else
return false;
}