Please help unconfuse me
Posted: Wed Dec 09, 2009 3:19 am
I am quite new to php and I am using joomla and a component called JEA for a estate agents site they wanted to implement a "save property" function for the users so this is how I went about testing the theory (please excuse the code I know it could be better.)
I created a new table called jos_jea_saved this contains the following structure:
user_id | ref | property_id
this is the code I made to test listing the users saved properties
so the database with 2 users would look like this:
user_id | ref | property_id
62 | p1345/p6753/p1297 | 1/67/92
64 | p1330/p6489 | 10/65
Ok it works even if the coding isn't very good and I can easily add new properties to this data HOWEVER I just realised it is going to be almost impossible to delete a property from this... where have I gone wrong?
Sorry this is so long, Thanks guys
I created a new table called jos_jea_saved this contains the following structure:
user_id | ref | property_id
this is the code I made to test listing the users saved properties
Code: Select all
// Display saved properties test
$user =& JFactory::getUser();
$query = "Select * from jos_jea_saved WHERE user_id = $user->id";
$result = mysql_query($query);
while($r = mysql_fetch_array($result)) {
$saved = split("[/]",($r["ref"]));
$saved_id = split("[/]",($r["property_id"]));
$newa = (array_combine($saved,$saved_id));
}
foreach( $newa as $key => $value){
echo "<a href='http://lawrencesanderson.co.uk/romancity/index.php?option=com_jea&view=properties&Itemid=3&id=$value'>" . $key . "</a>";
echo "<br>";
}user_id | ref | property_id
62 | p1345/p6753/p1297 | 1/67/92
64 | p1330/p6489 | 10/65
Ok it works even if the coding isn't very good and I can easily add new properties to this data HOWEVER I just realised it is going to be almost impossible to delete a property from this... where have I gone wrong?
Sorry this is so long, Thanks guys