Greywacke Posted March 31, 2010 Share Posted March 31, 2010 hi there,i'm retrieving a list of attributes from a database in php, and i need to get the attribute values of 3 specific attributes.here follows the code: $attr = split("<br />",$row1["text_LeadAttributes"]);$req = "";$mak = "";$stl = "";foreach ($attr as $value) { $val = split($value," = "); if (stristr($val[0],"product")) { $req = trim($val[1]); } elseif (stristr($val[0],"make_model")) { $mak = trim($val[1]); } elseif (stristr($val[0],"style")) { $stl = trim($val[1]); }}if (strlen($req)==0) { $req = $mak." ".$stl; }// print make / style attribute valueecho " <makestyle>" . xmlentities($req) . "</makestyle>\n"; as is, this code prints the following as <makestyle> value: <makestyle> </makestyle> now the leads are entered into the database from two sources, one has products_description as the combined make / style, or the other vehicle_make_model and canopy_style attributes. the lead attribute values retrieved from the database are formatted like follows from the second source: canopy_req = pre-owned_white<br />canopy_style = low_or_highline_standard<br />budget = R4,000 to R5,000<br />fitment = within_3_months<br />vehicle_status = possession_yes<br />vehicle_make_model = Isuzu - DCAB<br />year_model = 2003and formatted as follows from the first source:products_description = GWM LWB Canopy - Half Door<br />Bakkie model = 2007 - current model<br />Requirement = Pre-owned - White<br />Colour code = White Non-coded (standard)<br />Budget = R3,000 to R4,000<br />Fitment = ASAPthere are no errors, however - these values do not print. the records exist in the database, and theoretically i should be able to retrieve the attribute values.perhaps i need to split by any html tag using regular expressions in php?i am afraid i do not understand why this would not be working as expected.any assistance provided would be greatly appreciated! Link to comment Share on other sites More sharing options...
Err Posted March 31, 2010 Share Posted March 31, 2010 Shouldn't $val = split($value," = "); actually be $val = split(" = ",$value);?It's helpful if you have error reporting on to see what error and warnings you get. Link to comment Share on other sites More sharing options...
jeffman Posted March 31, 2010 Share Posted March 31, 2010 Yup. Also be aware that the manual now deprecates split and recommends using preg_split() instead. Link to comment Share on other sites More sharing options...
Greywacke Posted March 31, 2010 Author Share Posted March 31, 2010 ah thanks RahXephon for noticing that :)i guess it's late, i'm tired - guess my focus of intention is a little faded atm... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.