ротация на снимки и запис на показванията?

jooorooo

Registered
Добро утро :)
значи имам следното скриптче:

Код:
<?php
// Connect to the database
mysql_connect ('localhost', 'ime', 'parola') ;
mysql_select_db ('db'); 

// Edit this number to however many links you want displaying
$num_displayed = 1 ;

// Select random rows from the database
$result = mysql_query ("SELECT * FROM links ORDER BY RAND() LIMIT $num_displayed"); 

// For all the rows that you selected
while ($row = mysql_fetch_array($result)) 

{
// Display them to the screen...

echo "<a target=\"_new \" href=\"click.php?url=" . $row["url"] . "\">
<img width=\"" . $row["width"] . "\"  height=\"" . $row["height"] . "\" src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;
}
?>

ето я и базата:

Код:
CREATE TABLE `links` (
  `id` int(11) NOT NULL auto_increment,
  `url` text NOT NULL,
  `image` longtext NOT NULL,
  `text` text NOT NULL,
  `width` text NOT NULL,
  `height` text NOT NULL,
  PRIMARY KEY  (`id`)
);

та въпроса е как да се направи, да записва колко пъти е показана снимката, примерно ако е по лесно в една нова база. да речеме нещо такова

Код:
CREATE TABLE `shows` (
  `id_p` int(11) NOT NULL auto_increment,
  `id` text NOT NULL,
  `show` text NOT NULL,
  PRIMARY KEY  (`id_p`)
);

където връзката м-у двете таблици е id примерно. 10x

а може и в links таблицата да се записват показванията.
 
В таблицата links си правиш едно поле broi и после добавяш
в скрипта 2 реда (както съм показал).


<?php
// Connect to the database
mysql_connect ('localhost', 'ime', 'parola') ;
mysql_select_db ('db');

// Edit this number to however many links you want displaying
$num_displayed = 1 ;

// Select random rows from the database
$result = mysql_query ("SELECT * FROM links ORDER BY RAND() LIMIT $num_displayed");

// For all the rows that you selected
while ($row = mysql_fetch_array($result))

{
// Display them to the screen...

echo "<a target=\"_new \" href=\"click.php?url=" . $row["url"] . "\">
<img width=\"" . $row["width"] . "\" height=\"" . $row["height"] . "\" src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;

$id=$row["id"];
mysql_query("UPDATE links SET broi = broi + 1 where id='$id' ");
echo '<br/>Снимката е показана: '.$row["broi"].' пъти';

}
?>
 

Back
Горе