Jump to content

[SOLVED] php/ mysql problem


beboo002

Recommended Posts

hello freaks

i hav wrritten a script which is show the name via mysql database now i want each time its show only two name and after refresh the page Previous name replace to next new two name. here i am paste my script which show one name and after each refresh it print new name.

 

<?php

$link=mysql_connect("localhost","root","");

if(!$link) die("can not connect to mysql");

mysql_select_db("timesheet",$link);

$sql2="select firstName from employeeinfo order by rand() ";

$result2=mysql_query($sql2,$link) or die("Error: ". mysql_error(). " with query ". $sql2);

$query1=mysql_fetch_array($result2);

echo "<table border=1 align = center>";

echo $query1['firstName'];

echo "</table>";

mysql_close($link);

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/67409-solved-php-mysql-problem/
Share on other sites

<?php
$link=mysql_connect("localhost","root","");
if(!$link) die("can not connect to mysql");
mysql_select_db("timesheet",$link);

$query = "SELECT firstName FROM employeeinfo ORDER BY RAND() LIMIT 2"
$result=mysql_query($query, $link) or die("Error: ". mysql_error(). " with query ". $query);

echo "<table border=\"1\" align=\"center\">";
while ($record = mysql_fetch_assoc($result)) {
  echo "<tr><td>{$record['firstname']}</td></tr>";
}

mysql_close($link);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.