Hello,
Im a newbie to the forum and the (daunting) world of mySQL and PHP!
I am trying to create a ticker in Flash getting the variables from an external textfield which is easy enough.
I now want the textfile to get updated when I add new data to the mySQL table by selecting the last 3 entries sorted by what date they were added.
Through various searches I have managed to put the below code together. It works fine, placing the rows nice and neatly into a table.
<?php
$db = mysql_connect("localhost","root");
mysql_select_db("pane",$db);
$smallresult= mysql_query("SELECT * FROM news ORDER BY whatdate DESC limit 3",$db);
echo "<table border=1 width=400>\n";
while($myrow2 = mysql_fetch_array($smallresult)){
printf ("<tr><td>%s<br>%s<br>For more information click <a href='%s' target='_blank'>here</a> Posted by %s on %s</td><tr>\n",
$myrow2["kopf"],$myrow2["inhalt"], $myrow2["mehr"], $myrow2["posted"], $myrow2["wann"]);
}
echo "</table>\n";
?>
How would i go about getting the newest 3 entries of "inhalt" into a single variable so that I can then save them to a textfile in this sort of fashion:
&tick=the content from the first row of inhalt&tick2=content from the second row of inhalt&tick3=you guessed it !!!&
All the examples I have found always use printf which I dont think will let me put it into a variable, maybe in some sort of loop like
$var=1;
while($myrow2 = mysql_fetch_array($smallresult)){
printf("&tick".$var."=%s",$myrow2["inhalt"]);
$var ++;
}
I would appreciate any help anyone can give me.
Thanks for reading!