Skip to main content
Participant
December 3, 2008
Question

some help in php code plz?

  • December 3, 2008
  • 2 replies
  • 389 views
Hi Guys, I have been given a task to convert the code of PHP to Coldfusion. However I am Stuck at this PHp Stuff.

Please Guide Me
PHP Code:
$result = mysql_query("select cid, title, cdesc from cat where parentid=0 order by title", $link);
$count =1;
$displaycat="<tr>";
while(list($cid, $title, $cdesc) = mysql_fetch_row($result)) {
$sql=mysql_query("SELECT count(list.listid) AS totallist, count(cat.cid) as totalcat FROM list LEFT JOIN cat ON list.cid = cat.cid WHERE list.cid =cat.cid AND cat.parentid='$cid' or cat.cid ='$cid' AND active='1'",$link) or die("Error".mysql_error());
list($totallist,$totalcat)=mysql_fetch_row($sql);
$displaycat.="<td class=\"nowconvert\"><br><strong><a href=\"index.php?cid=$cid\">$title ($totallist)</a></strong><br>";
$result2 = mysql_query("select cid, title from cat where parentid=$cid order by title limit 0,2", $link);
$space = 0;
while(list($cid, $stitle) = mysql_fetch_row($result2)) {
if ($space>0) {
$displaycat.=", ";
}
$cresult2 = mysql_query("select * from list where cid='$cid'", $link);
$cnumrows2 = mysql_num_rows($cresult2);
$displaycat.="<a href=\"index.php?cid=$cid\">$stitle</a></span>";
$space++;
}


I am Confused at this Guys.

Please help me Guys Thanks

This topic has been closed for replies.

2 replies

Inspiring
December 10, 2008
Basically, the PHP code you see there is simply grabbing some details out of a DB and then outputting it. The code runs a query, storing the results as variables with the PHP list "function". It then iterates over the initial query to build up an output string ($displaycat), as well as running other queries. It is hard to tell exactly what the code is doing since it's not a full code listing (i.e., how are the variables $cresult2 or $cnumrows2 being used?).

I attached a basic CFML code block to illustrate the steps it appears your PHP code taking. Since the PHP provided is just a snippet, my CF block is merely a basic example of what I see the PHP code doing.

As Daverms notes, however, it's a good idea to essentially reverse engineer the PHP. See what it's outputting, compare that to the database, and then try to replicate with CF. My hope is that the CFML code snippet helps get you started and, if not, sorry!
Inspiring
December 4, 2008
Hi,

The best thing you can do is, Run that php code and try to learn from the output that it produces, and then write your own code in coldfusion.