Hi everyone,
I have a main page where I have to bring data from 3 different tables in my database and the way I'm doing it is by creating 3 different php pages where I connect to my database and select the data I want. Then in my main page all I do is this:
include('events/my_page1.php');
include('events/my_page2.php');
include('events/my_page3.php');
The data from my_page1 is showing pretty well on my main page, but not the others. I already check those pages and they are selecting the values well because I added an echo mysql_result and I can see the data, but not in my main page.
This is my_page2.php
$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name=""; // Table name
//Connect to server and select databse.
$con=mysql_connect("$host", "$username", "$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("$db_name", $con);
mysql_select_db("$db_name")or die("cannot select DB");
$sql= "select post from my_table2 order by id desc limit 1";
$result_s1=mysql_query($sql,$con);
$sql2= "select post1 from my_table2 order by id desc limit 1";
$result_s2=mysql_query($sql2,$con);
$sql3= "select post2 from my_table2 order by id desc limit 1";
$result_s3=mysql_query($sql3,$con);
$sql4= "select post3 from my_table2 order by id desc limit 1";
$result_s4=mysql_query($sql4,$con);
echo mysql_result($result_s1,0);
mysql_close($con);
Can you guys please help me?