This topic is locked

results in citymenue demo real estates

2/16/2007 3:54:19 AM
PHPRunner General questions
samsp author

hi there,
i like to know, how to get the numbers of cities behind the cityname in the like in the demo of real estates?? is there a way?
greeting
sam

J
Jane 2/16/2007

Sam,
all menu items are created in the ListOnLoad event.

Here is a sample code:

$message="";

$str = "select count(ID) as numbers, Town from TableName group by Town";

$rs = db_query($str,$conn);

while ($data = db_fetch_array($rs))

{

$town= str_replace(" ","+",$data["Town"]);

$message = "<a href=\"cars_list.php?a=search&value=1&SearchFor=".$town."&SearchOption=Contains&SearchField=Town\">".$data["Town"]." (".$data["numbers"].")</a>";

echo $message."
";

}

samsp author 2/17/2007

Hi jane,
thank you for suggestion, it works.
sam <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=15596&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

M
mmponline 2/17/2007

Sam

I'm not getting this>

  1. Do I add the code on the specific table's Events on the List Page: On Laod - I tried - get parse error.

    Parse error: parse error, unexpected $ in /usr/www/users/golfen/golfendb/include/_Tournaments_events.php on line 16
  2. If I have Table: _Tournamentsand ID: TourID and the table I want the totals on: TournamentName, what would the code look like?
    My code that does not work:
    function ListOnLoad()

    {

    $message="";

    $str = "select count(ID) (Tried TourID as well) as numbers, TournamentName from _Tournaments group by TournamentName";

    $rs = db_query($str,$conn);

    while ($data = db_fetch_array($rs))

    {

    $town= str_replace(" ","+",$data["TournamentName"]);

    $message = "<a href=\"_Tournaments_List.php?a=search&value=1&SearchFor=".$TournamentName."&SearchOption=Contains&SearchField=_TournamentName\">".$data["TournamentName"]." (".$data["numbers"].")</a>";

    echo $message."
    ";

    }

J
Jane 2/19/2007

Stephan,
there are two sintax errors in your code: you've forgot closed bracket } and used undefined variable $TournamentName.

Here is the correct code:

function ListOnLoad()

{

$message="";

$str = "select count(TourID) as numbers, TournamentName from _Tournaments group by TournamentName";

$rs = db_query($str,$conn);

while ($data = db_fetch_array($rs))

{

$TournamentName= str_replace(" ","+",$data["TournamentName"]);

$message = "<a href=\"_Tournaments_List.php?a=search&value=1&SearchFor=".$TournamentName."&SearchOption=Contains&SearchField=TournamentName\">".$data["TournamentName"]." (".$data["numbers"].")</a>";

echo $message."
";

}

}



I strongly recommend you to learn PHP and SQL before writing your events:

http://www.webcheatsheet.com/php/

http://www.w3schools.com/php/default.asp

http://www.php.net/manual/en/