[ mmisko75 @ 07.10.2013. 21:01 ] @
Pozdrav svima, imam jedan problem. Pravim xml fajl za jedan sajt sa nekretninama preko php-a. Za sada je sve išlo dobro i podaci se lepo prikazuju u xml fajlu, medjutim imam problem sa dodavanjem url-a slika za jednu nekretninu. Slike treba da budu ugnežđene pod tagom <slike><slika>url slike</slika><slike>. Meni jedino uspeva prikaz jedne slike za svaku nekretninu, ili prikaz svih mogućih slika, ali u jednoj nekretnini, a ostale ništa. Kod izvornog fajla: Code (php): <?php require_once('../Connections/antre011.php'); ?> <?php header('Content-type: application/xml');echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_antre011, $antre011); $query_record2 = "SELECT jml_iproperty_images.title, jml_iproperty_images.propid, jml_iproperty_images.`path`, jml_iproperty_images.type, jml_iproperty.id, jml_iproperty_images.fname FROM jml_iproperty_images, jml_iproperty WHERE jml_iproperty.id = jml_iproperty_images.propid"; $record2 = mysql_query($query_record2, $antre011) or die(mysql_error()); $row_record2 = mysql_fetch_assoc($record2); $totalRows_record2 = mysql_num_rows($record2); mysql_select_db($database_antre011, $antre011); $query_record = "select jml_iproperty.id, jml_iproperty.stype, jml_iproperty.street, jml_iproperty.beds, jml_iproperty.style, jml_iproperty.sqft, jml_iproperty.price, jml_iproperty.yearbuilt, jml_iproperty.lot_type, jml_iproperty.fuel, jml_iproperty.cool, jml_iproperty.apt, jml_iproperty.lot_acres, jml_iproperty.lotsize, jml_iproperty.baths, jml_iproperty.heat, jml_iproperty.garage_type, jml_iproperty.garage_size, jml_iproperty.reception, jml_iproperty.tax, jml_iproperty.income, jml_iproperty.zoning, jml_iproperty.propview, jml_iproperty.short_description, UNIX_TIMESTAMP(jml_iproperty.created), jml_iproperty.state, jml_iproperty_categories.alias, jml_iproperty_countries.mc_name from jml_iproperty left join jml_iproperty_propmid on jml_iproperty.id= jml_iproperty_propmid.prop_id left join jml_iproperty_countries on jml_iproperty_countries.id=jml_iproperty.country left join jml_iproperty_categories on jml_iproperty_propmid.cat_id=jml_iproperty_categories.id where jml_iproperty_categories.id IS NOT NULL and jml_iproperty_categories.alias<>'garaze' and jml_iproperty_categories.alias<>'gradjevinsko' and jml_iproperty_categories.alias<>'obradivo' and jml_iproperty_categories.alias<>'pomocni-objekti' and jml_iproperty_categories.alias<>'skladista' and jml_iproperty_categories.alias<>'sobe' and jml_iproperty_categories.alias<>'turizam' and jml_iproperty_categories.alias<>'ugostiteljski-objekti' and jml_iproperty_categories.alias<>'zemljista';"; mysql_set_charset('utf8'); $record = mysql_query($query_record, $antre011) or die(mysql_error()); $row_record = mysql_fetch_assoc($record); $totalRows_record = mysql_num_rows($record); $nekretnina1 = $row_record['id']; $nekretnina2 = $row_record2['propid']; echo '<oglasi>'; while($row_record = mysql_fetch_array($record)) { ?> <oglas> <id><?php echo $row_record['id']; ?></id> <tip><?php if ($row_record['stype'] == "4") { echo "2"; } elseif ($row_record['stype'] == "1") { echo "1"; } else { echo "-1"; } ?></tip> <kraj><?php echo $row_record['mc_name']; ?></kraj> <struktura><?php $struktura = $row_record['alias']; if ($struktura == "kuce") { echo "2"; } elseif ($struktura == "poslovni-prostor") { echo "3"; } elseif ($struktura == "lokali") { echo "3"; } elseif ($struktura == "poslovni-objekti") { echo "3"; } elseif ($struktura == "05garsonjere") { echo "1"; } elseif ($struktura == "1-jednosobni") { echo "1"; } elseif ($struktura == "1-5-jednoiposobni") { echo "1"; } elseif ($struktura == "2-0-dvosobni") { echo "1"; } elseif ($struktura == "2-5-dvoiposobni") { echo "1"; } elseif ($struktura == "3-0-trosobni") { echo "1"; } elseif ($struktura == "3-5-troiposobni") { echo "1"; } elseif ($struktura == "4-0-cetvorosobniplus") { echo "1"; } else { echo "-1"; } ?></struktura> <adresa><?php echo $row_record['street']; ?></adresa> <broj_soba><?php echo $row_record['beds']; ?></broj_soba> <broj_etaza><?php echo $row_record['style']; ?></broj_etaza> <povrsina><?php echo $row_record['sqft']; ?></povrsina> <cena><?php echo floor ($row_record['price']); ?></cena> <godiste><?php if ($row_record['yearbuilt'] == "") { echo ""; } else { echo $row_record['yearbuilt']; } ?></godiste> <uknjizen><?php if ($row_record['lot_type'] == "DA") { echo "1"; } else { echo "-1"; } ?></uknjizen> <stanje><?php if ($row_record['fuel'] == "novo") { echo "2"; } elseif ($row_record['fuel'] == "u izgradnji") { echo "3"; } elseif ($row_record['fuel'] == "renovirano") { echo "4"; } elseif ($row_record['fuel'] == "potrebno renoviranje") { echo "5"; } else { echo "1"; } ?></stanje> <useljivo>1</useljivo> <opremljenost><?php if ($row_record['cool'] == "prazno") { echo "1"; } elseif ($row_record['cool'] == "nameteno") { echo "3"; } else { echo "2"; } ?></opremljenost> <sprat><?php if ($row_record['apt'] == "suteren") { echo "-4"; } elseif ($row_record['apt'] == "nisko prizemlje") { echo "-3"; } elseif ($row_record['apt'] == "prizemlje") { echo "-2"; } elseif ($row_record['apt'] == "visoko prizemlje") { echo "-1"; } else { echo $row_record['apt']; } ?></sprat> <plac><?php if ($row_record['lot_acres'] == "") { echo ""; } else { echo $row_record['lot_acres']; } ?></plac> <terasa><?php if ($row_record['lotsize'] == "") { echo "-1"; } elseif ($row_record['lotsize'] == "ne") { echo "-1"; } elseif ($row_record['lotsize'] == "da") { echo "1"; } else { echo $row_record['lotsize']; } ?></terasa> <kupatilo><?php if ($row_record['baths'] == "0") { echo "-1"; } else { echo floor ($row_record['baths']); } ?></kupatilo> <grejanje><?php if ($row_record['heat'] == "CG") { echo "1"; } elseif ($row_record['heat'] == "EG") { echo "2"; } elseif ($row_record['heat'] == "gas") { echo "4"; } elseif ($row_record['heat'] == "kaljeva") { echo "5"; } elseif ($row_record['heat'] == "norveki") { echo "6"; } elseif ($row_record['heat'] == "podno") { echo "7"; } else { echo "3"; } ?></grejanje> <telefon><?php if ($row_record['garage_type'] == "") { echo "0"; } else { echo $row_record['garage_type']; } ?></telefon> <kablovska><?php if ($row_record['garage_size'] == "DA") { echo "1"; } else { echo "-1"; } ?></kablovska> <internet><?php if ($row_record['reception'] == "da") { echo "1"; } elseif ($row_record['reception'] == "dial-up") { echo "2"; } elseif ($row_record['reception'] == "adsl") { echo "3"; } elseif ($row_record['reception'] == "kablovski") { echo "4"; } else { echo "-1"; } ?></internet> <lift><?php if ($row_record['tax'] == "da") { echo "1"; } elseif ($row_record['tax'] == "ne") { echo "-1"; } elseif ($row_record['tax'] == "") { echo "-1"; } else { echo $row_record['tax']; } ?></lift> <interfon><?php if ($row_record['income'] == "da") { echo "1"; } else { echo "-1"; } ?></interfon> <garaza><?php if ($row_record['zoning'] == "da") { echo "1"; } elseif ($row_record['zoning'] == "ne") { echo "-1"; } elseif ($row_record['zoning'] == "") { echo "-1"; } else { echo $row_record['zoning']; } ?></garaza> <parking><?php if ($row_record['propview'] == "da") { echo "1"; } elseif ($row_record['propview'] == "ne") { echo "-1"; } elseif ($row_record['propview'] == "") { echo "-1"; } else { echo $row_record['propview']; } ?></parking> <opis><?php echo $row_record['short_description']; ?></opis> <azuriran><?php echo $row_record['UNIX_TIMESTAMP(jml_iproperty.created)']; ?></azuriran> <slike> <?php echo "<slika>"; echo "http://www.antre011.rs"; echo implode ($row_record2['path']); echo implode ($row_record2['fname']); echo implode ($row_record2['type']); echo "</slika>"; //} while ($row_record2 = mysql_fetch_assoc($record2)); //mysql_free_result($record2); ?> </slike> </oglas> <?php } echo "</oglasi>"; //mysql_free_result($record); ?> Ima li neko rešenje za prikaz svih slika za jednu nekretninu u nizu a da se nekretnina ne ponavlja onoliko puta koliko ima slika ... Hvala :) |