Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cabbit

macrumors 68020
Original poster
Jan 30, 2006
2,128
1
Scotland
i would like to add another php print to this, but i dont know how to do it. i've included the bit i want to add to the string and the link it needs to effect.

Code:
<?php
printf("<tr><td><a href=\"javascript:ajaxpage('/includes-functions/
story_display.php?id=%s<<?usrname=<?php print $usrname2; ?>>>', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>
 
i would like to add another php print to this, but i dont know how to do it. i've included the bit i want to add to the string and the link it needs to effect.

Code:
<?php
printf("<tr><td><a href=\"javascript:ajaxpage('/includes-functions/
story_display.php?id=%s<<?usrname=<?php print $usrname2; ?>>>', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>
You can't nest prints as far as I know. But there's no reason to anyway.

$aaa = "cat";
$bbb = "dog";

print "I have a $aaa and a $bbb."; ---> "I have a cat and a dog."

or

print "I have a " . $aaa . " and a " . $bbb ".";

If you're trying to do what it looks like you're trying to do, try this:

Code:
printf("<tr><td><a href=\"javascript:ajaxpage('/includes-functions/
story_display.php?id=%s&usrname=$usrname2', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
 
That's a lot of weird stuff you have going on there...

Code:
<?php
printf("<tr><td><a href=\"javascript:ajaxpage('/includes-functions/
story_display.php?id=%s<$usrname2>>', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>
 
That's a lot of weird stuff you have going on there...

Code:
<?php
printf("<tr><td><a href=\"javascript:ajaxpage('/includes-functions/
story_display.php?id=%s<$usrname2>>', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>

im trying to make the entire site with ajax some things transfer easy some don't, but the site is really really fast.
 
im trying to make the entire site with ajax some things transfer easy some don't, but the site is really really fast.

Why are you doing so?

Because in general, it is a bad idea to create an entire site in Ajax (if I understand your meaning). This is because not all browsers support Javascript or have Javascript enabled. It is therefore preferable to start with a normal site, and then add Ajax. Of course, you can make sure that all the back-end is generic and can be reused for both HTML and Ajax output.

However, it is perfectly alright to make a website entirely in Ajax for the sake of an experiment.

As for your print statement:
PHP:
<?php
printf("<tr><td><a href=\"javascript:ajaxpage('/includes-functions/
story_display.php?id=%s<<?usrname=<?php print $usrname2; ?>>>', 'contentarea');\">%s</a></td><td><span style=\"TEXT-ALIGN:center\">%s</span></td>", $row["id"], $row["title"], $row["author"], $row["id"]);
}
?>

Why not break it down into pieces:
PHP:
echo "<tr>";
echo "<td><a href=\"javascript:ajaxpage('/includes-functions/story_display?id=", $row["id"];
echo "&usrname=", $usrname2;
echo "','contentarea');\">", $row["title"], "</a></td>";
echo "<td style=\"text-align:center\">", $row["title"], "</td>";
echo "</tr>";
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.