By leo3911 on
I am using Drupal for construction of the service centre supporting big databases. I managed already to create the form asking and showing results of the inquiry PHP code. How I already marked ą these are big databases so as a result of the inquiry many records can appear, of course I would like can show them divided let us say after 10 on many sides. Unfortunately in spite of many trials at the moment I am not making a success of it. So I am not a typical programmer and ask the straight line just enough for possible advice. I am presenting the demonstration and straightest code which I wrote to service questions to the database. Please help.
Leo
Name
//creating short names
$name = $_POST['name'];
//basic condition without which nothing explane
if($name) {
//condition of asking to the databases
if (
//asking to the databases
$result = db_query("SELECT * FROM table1 WHERE f_name='$name'
UNION ALL
SELECT * FROM table2 WHERE f_name='$name'
")
)
//is showing the amount of found
$i = db_affected_rows($result);
echo 'ilość znależionych osób: '.$i."<br />";
//assigning variables to value of fields of the database
$year = 'year';
$time = 'time';
$s_name = 's_name';
$f_name = 'f_name';
//is showing the result of asking
while($rek = db_fetch_array($result)) {
if (!empty($rek[$year])) echo '<font color="#336699"><i>year</i>:</font>'.$rek[$year]." ";
if (!empty($rek[$time])) echo '<font color="#336699"><i>time</i>:</font>'.$rek[$time];
echo "<br/>";
if (!empty($rek[$f_name])) echo '<font color="#336699"><i>first name</i>:</font>'.$rek[$f_name]." ";
if (!empty($rek[$s_name])) echo '<font color="#336699"><i>second name</i>:</font>'.$rek[$s_name];
echo "<br/><br/>";
}
}