Jump to content

Need help getting some row info


monkeybidz

Recommended Posts

I am trying to display an image when an auction is set to private. Below you will see the code that has the query and works fine, the trouble I am having is near the bottom where I try to determine if auction is private or not.

 

<?php


$query = "select id, title, pict_url, category, photo_uploaded, city_details1, city_details2, state1, state2, miles, starts from PHPAUCTIONREVERSE_auctions
         WHERE
         closed='0' AND
         suspended=0 AND
         private='n' OR private='y' AND ";
	 if($SETTINGS['adultonly']=='y' && !isset($_SESSION["PHPAUCTION_LOGGED_IN"])){
		 $query .= "adultonly='n' AND ";
	 }
         $query .= "starts<=".$NOW."
         ORDER BY starts DESC
         LIMIT ".$SETTINGS['lastitemsnumber'];
$result = mysql_query($query);
if ( $result )
$num_auction = mysql_num_rows($result);
else
$num_auction = 0;

$i = 0;
$bgcolor = "#FFFFFF";
$TPL_last_auctions_value .= "";
while($i < $num_auction) {
if($bgcolor == "#FFFFFF") {
	$bgcolor = $FONTCOLOR[$SETTINGS['headercolor']];
} else {
	$bgcolor = "#FFFFFF";
}
$title = mysql_result($result,$i,"title");
    $category = mysql_result($result,$i,"category");
    $city_details1 =  mysql_result($result,$i,"city_details1");
    $city_details2 =  mysql_result($result,$i,"city_details2");
    $state1 =  mysql_result($result,$i,"state1");
    $state2 =  mysql_result($result,$i,"state2");
    $miles =  mysql_result($result,$i,"miles");
$id 	 = mysql_result($result,$i,"id");
$date	 = mysql_result($result,$i,"starts");

$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6,2);
$hours = substr($date,8,2);
$minutes = substr($date,10,2);
$seconds = substr($date,12,2);
    


include("./includes/thumbimage.php");

//Determine weather job is private or not to display private icon.

if(mysql_query($query,$i,[private])== 'y'){// <---- <---- THIS LINE IS MY PROBLEM. I KNOW CODE IS WRONG
   $private_icon = "<img src=\"./images/lock_icon.gif\" height=\"10\" width=\"10\">";
}else{
   $private_icon = "";
}

///////////////////////////////////////////////////////////////


?>

Link to comment
https://forums.phpfreaks.com/topic/92954-need-help-getting-some-row-info/
Share on other sites

This should work for you. Read my comments in the code that start with ##

 

<?php

## Need to add private to select fields
$query = "select id, title, pict_url, category, photo_uploaded, city_details1, city_details2, state1, state2, miles, starts, private from PHPAUCTIONREVERSE_auctions
         WHERE
         closed='0' AND
         suspended=0 AND
         private='n' OR private='y' AND ";
	 if($SETTINGS['adultonly']=='y' && !isset($_SESSION["PHPAUCTION_LOGGED_IN"])){
		 $query .= "adultonly='n' AND ";
	 }
         $query .= "starts<=".$NOW."
         ORDER BY starts DESC
         LIMIT ".$SETTINGS['lastitemsnumber'];
$result = mysql_query($query);
if ( $result )
$num_auction = mysql_num_rows($result);
else
$num_auction = 0;

$i = 0;
$bgcolor = "#FFFFFF";
$TPL_last_auctions_value .= "";
while($i < $num_auction) {
if($bgcolor == "#FFFFFF") {
	$bgcolor = $FONTCOLOR[$SETTINGS['headercolor']];
} else {
	$bgcolor = "#FFFFFF";
}
$title = mysql_result($result,$i,"title");
    $category = mysql_result($result,$i,"category");
    $city_details1 =  mysql_result($result,$i,"city_details1");
    $city_details2 =  mysql_result($result,$i,"city_details2");
    $state1 =  mysql_result($result,$i,"state1");
    $state2 =  mysql_result($result,$i,"state2");
    $miles =  mysql_result($result,$i,"miles");
$id 	 = mysql_result($result,$i,"id");
$date	 = mysql_result($result,$i,"starts");
## To be consistent, let's store private into a variable
$private = mysql_result($result,$i,"private");

$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6,2);
$hours = substr($date,8,2);
$minutes = substr($date,10,2);
$seconds = substr($date,12,2);
    


include("./includes/thumbimage.php");

//Determine weather job is private or not to display private icon.
if($private == 'y'){ ## Now we just check the value of $private
   $private_icon = "<img src=\"./images/lock_icon.gif\" height=\"10\" width=\"10\">";
}else{
   $private_icon = "";
}

} ## Added this close brace, I assume you left off when you copy/pasted
///////////////////////////////////////////////////////////////


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.