php / mambo help


#1

hi, please forgive me as im very new to all this ( php & mambo ), i am making a component that will display the content of a table in my DB.

i am using the userlist as a template for this and have so far gotten it too work it displays the content of the table :D.

one of the fields is sex ( male / female ) and at the moment it just returns the content of the cell ( either a 0 for male or a 1 for female ) what i want too do is make it display one image for male and another image for female, but as hard as i try i cant work out how to do this.

so im hoping someone can help me out :?:

here is the code:

[code]<?php
//Mambo se7enlist//
//
// Description : se7enlist
// Created : 04-Aug-2003 23:36 by Emir Sakic
// Updated :
// Version : 2.0
//
// Copyright © 2000-2003 Miro International Pty Ltd
// All rights reserved. Mambo Open Source is Free Software
// released under the GNU/GPL License.
//
// This source file is part of the Mambo Open Source Content
// Management System.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// The “GNU General Public License” (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.

defined( ‘_VALID_MOS’ ) or die( ‘Direct Access to this location is not allowed.’ );

/* SET YOUR VARIABLES HERE */
$rows_per_page = 30; // set how many rows per page you want displayed
$pages_in_list = 10; // set how many pages you want displayed in the menu
$email_displayed = 0; // set this value to 1 if you want users emails to be displayed

// Translation can be done here
DEFINE (’_USRL_SE7ENLIST’,‘SE7ENLIST’);
DEFINE (’_USRL_NUMBER’,‘Car No.’);
DEFINE (’_USRL_NAME’,‘Name’);
DEFINE (’_USRL_NATIONALITY’,‘Nationality’);
DEFINE (’_USRL_DOB’,‘D.O.B.’);
DEFINE (’_USRL_SEX’,‘Sex’);
DEFINE (’_USRL_SPONSOR’,‘Sponsor’);
DEFINE (’_USRL_TEAM’,‘Team’);
DEFINE (’_USRL_CAR_SKIN’,‘Car skin’);
DEFINE (’_USRL_DRIVER_SKIN’,‘Driver skin’);
DEFINE (’_USRL_PIT_SKIN’,‘Pit skin’);
DEFINE (’_USRL_PICS’,‘Pics’);

/* NO CHANGES BELOW THIS LINE (unless you know what you are doing) */
$version = “0.5”; // script version

// Find out $Itemid
$database->setQuery(“SELECT id FROM #__menu WHERE link = ‘index.php?option=com_se7enlist’”);
$usrlItemid = $database->loadResult();
$usrl_base_url = “index.php?option=com_se7enlist&Itemid=” . $usrlItemid; // Base URL string

// Total
$database->setQuery(“SELECT count(id) FROM #__users”);
$total_results = $database->loadResult();

// Search total
$query = “SELECT count(id) FROM #__users”;
if (isset($search) && $search != “”) {
$query .= " WHERE (name LIKE ‘%$search%’ OR username LIKE ‘%$search%’)";
}
$database->setQuery($query);
$total = $database->loadResult();

if (empty($limitstart)) $limitstart = 0;
$limit = $rows_per_page;
if ($limit > $total) {
$limitstart = 0;
}

$search_query = “”;

// Select query
$query = “SELECT number, name, nationality, dob, sex, sponsor, team, car_skin, driver_skin, pit_skin, pics FROM #__se7en”;
if (isset($search) && $search != “”) {
$query .= " WHERE (name LIKE ‘%$search%’ OR username LIKE ‘%$search%’)";
$search_query = “&search=”.$search;
}
$query .= " LIMIT $limitstart, $limit";
$database->setQuery($query);
$usrl_rows = $database->loadObjectList();
?>

<?php $i = 1; foreach($usrl_rows as $usrl_row) { $evenodd = $i % 2; if ($evenodd == 0) { $usrl_class = "sectiontableentry1"; } else { $usrl_class = "sectiontableentry2"; } $nr=$i+$limitstart; print "t"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "tn"; $i++; } ?>
<?php echo _USRL_NUMBER; ?> <?php echo _USRL_NAME; ?> <?php echo _USRL_NATIONALITY; ?> <?php echo _USRL_DOB; ?> <?php echo _USRL_SEX; ?> <?php echo _USRL_SPONSOR; ?> <?php echo _USRL_TEAM; ?> <?php echo _USRL_CAR_SKIN; ?> <?php echo _USRL_DRIVER_SKIN; ?> <?php echo _USRL_PIT_SKIN; ?> <?php echo _USRL_PICS; ?>
$usrl_row->number$usrl_row->name$usrl_row->nationality$usrl_row->dob$usrl_row->sex$usrl_row->sponsor$usrl_row->team$usrl_row->car_skin$usrl_row->driver_skin$usrl_row->pit_skin$usrl_row->pics

[/code]

best regards


#2

Don’t know mambo but here is the pseudocode for PHP:

if (sex == 0)
{
    display male image
}
else
{
    display female image
}

#3

problem solved, thanks for the reply thow m8