Hi everyone and thanks for helping me out... I have 1 database and 3 queries at the same time. Every query is picking a different year and taking the data from that column.
This is my code
$items = array();
// while we still have rows from the db, display them
while ($row = mysql_fetch_array($result1)) {
$items[] = $row;
}
while ($row = mysql_fetch_array($result2)) {
$items[] = $row;
}
while ($row = mysql_fetch_array($result3)) {
$items[] = $row;
}
mysql_close($connect);
?>
<?php foreach($items as $key => $item) : ?>
<?php print "I DONT KNOW WHAT TO DO"; ?>
<?php endforeach; ?>
When I type:
<?php echo print_r($keys); ?>
I can see that I have an array of 0, 1 and 2. I would love to get a specific ROW from the first(1) or second(2) array.
I am trying to figure it out and I just cant...
Thank you all so much!
Edit:
Complete code:
<?php
include ('db.php'); // for db details
include ('functions.php');
$connect = @mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>');
if (!$connect) {
die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>');
$query1 = "SELECT * FROM godina2015 WHERE mjesec='8' AND godina='2015'";
$query2 = "SELECT * FROM godina2015 WHERE mjesec='7' AND godina='2015'";
$query3 = "SELECT * FROM godina2015 WHERE mjesec='6' AND godina='2015'";
$result1 = @mysql_query("$query1") or die('<p class="error">There was an unexpected error grabbing news from the database.</p>');
$result2 = @mysql_query("$query2") or die('<p class="error">There was an unexpected error grabbing news from the database.</p>');
$result3 = @mysql_query("$query3") or die('<p class="error">There was an unexpected error grabbing news from the database.</p>');
$items = array();
// while we still have rows from the db, display them
while ($row = mysql_fetch_array($result1)) {
$items[] = $row;
}
while ($row = mysql_fetch_array($result2)) {
$items[] = $row;
}
while ($row = mysql_fetch_array($result3)) {
$items[] = $row;
}
mysql_close($connect);
?>
<?php foreach($items as $key => $item) : ?>
<?php print_r ($item); ?>
<?php endforeach; ?>
EDIT #2
<?php
include ('db.php'); // for db details
include ('functions.php');
$connect = mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>');
if (!$connect) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>');
$query = "SELECT * FROM godina2015 WHERE mjesec IN(8,7,6) AND godina='2015'";
$result = mysql_query("$query") or die('<p class="error">There was an unexpected error grabbing news from the database.</p>');
$items = array();
// while we still have rows from the db, display them
while ($row = mysql_fetch_array($result)) {
$items[] = $row;
}
mysql_close($connect);
?>
<?php foreach($items as $key => $item) : ?>
<?php echo $items[1]['AWAsistCTR2']; ?>
<?php endforeach; ?>