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
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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.