Forum Moderators: coopster
<?php
$firstSp = mysql_query("SELECT bizID,bizName FROM biz_cars WHERE bizState='$bizState' AND bizCity='$bizCity' AND bizLive='1' GROUP BY bizName LIMIT $offset,1");
$first = mysql_fetch_array($firstSp);
?>
<?php
$secondSp = mysql_query("SELECT bizID,bizName FROM biz_cars WHERE bizState='$bizState' AND bizCity='$bizCity' AND bizLive='1' GROUP BY bizName LIMIT $newoffset,1");
$second = mysql_fetch_array($secondSp);
?>
<?php
$betterdesc = mysql_query("SELECT bizID,bizName FROM biz_cars WHERE bizState='$bizState' AND bizCity='$bizCity' AND bizLive='1' GROUP BY bizName LIMIT $newdesc,1");
$betterdesc = mysql_fetch_array($betterdesc);
?>
$query = "SELECT bizID,bizName FROM biz_cars WHERE bizState='$bizState' AND bizCity='$bizCity' AND bizLive='1' GROUP BY bizName LIMIT $offset,3";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$results[] = $row;
}
print_r($result[0]); //equivalent to your $first
print_r($result[1]); //equivalent to your $second
print_r($result[2]); //equivalent to your $bettersdesc
If that isn't what you were expecting, please post back with some more details about what you are trying to accomplish. :)
These are the different offsets:
<?php
$letter = strtoupper($_GET['letter']);
$newoffset = $_GET["newoffset"];
if(!$newoffset)
{
$newoffset = $offset+30;
}
?>
<?php
$letter = strtoupper($_GET['letter']);
$newo = $_GET["newo"];
if(!$newo)
{
$newo = $offset+31;
}
?>
<?php
$letter = strtoupper($_GET['letter']);
$newdesc = $_GET["newdesc"];
if(!$newdesc)
{
$newdesc = $offset+1;
}
?>
It is strange that print_r outputs the results, but not print and not echo. Print and Echo just output the word Array.
Is there a equivalent to print_r which will output just the array? I tried hundreds of possible combinations with echo and print, but it just shows the word Array.
foreach($result[1] as $value)
echo "$value<br>\n";
foreach($result[2] as $value)
echo "$value<br>\n";
$result[0] is an array, of the fields specified in your query. $result[1] is another array, and $result[2] is a third.
I need those empty arrays because in some cases they are empty (no output) and in some cases they are not empty (output).
Is there a way to avoid this Warning and first check if the array is empty?
[edited by: SEOPTI at 3:31 pm (utc) on Sep. 22, 2007]
Notice that the if has three equal signs in it. When checking for a value of false, it's a good idea to get into the habit of doing it that way - the third = makes it check the type of value in addition to the value of the value. Without the type check, there's no difference between zero and false, whereas sometimes zero is significant (in this case it's not, but if you're in the habit you don't have to think about it each time).