// DB Connection //
$MySQLPassword = "***";
$HostName = "***";
$UserName = "***";
$Database = "*****";
mysql_connect($HostName,$UserName,$MySQLPassword)
or die("ERROR: Could not connect to database!");
mysql_select_db($Database) or die("cannot select db");
// Data Sorting Variables //
/* The following are used to set the columns for data sorting */
/* Change these to the table field names in your MySQL database */
$default_sort = 'ID';
$allowed_order = array ('name','publication_date', 'price');
/* if order is not set, or it is not in the allowed
* list, then set it to a default value. Otherwise,
* set it to what was passed in. */
if (!isset ($_GET['order']) ||
!in_array ($_GET['order'], $allowed_order)) {
$order = $default_sort;
} else {
$order = $_GET['order'];
}
// The following line stops the undefined index error on initial page load
if (isset($_GET['keyword'])) {
if(!$_GET['keyword']) {
die('<p>Please enter a search term.</p>');
}
$tables = 'reports';
$return_fields = 'id name organizer_id no_pages publication_date price currency';
$check_fields = 'name';
// Get the keyword from the search form.
$query_text = $_GET['keyword'];
// Sanitize Data Input
$clean_query_text =cleanQuery($query_text);
// Call the bq_simple function and store the //
// resulting SQL Query in $newquery variable //
$newquery=bq_simple ($return_fields, $tables, $check_fields, $clean_query_text);
$newquery = $newquery . " ORDER BY $order;";
// sql data query construction //
$result = mysql_query($newquery) or die(mysql_error());
/* make sure data was retrieved */
$numrows = mysql_num_rows($result);
if ($numrows == 0) {
echo "<H4>No data to display!</H4>";
exit;
}
echo "<p>Your search '$query_text' returned ".$numrows. " results.</p>\n";
echo "<p>Click on the headings to sort.</p>\n";
/* now grab the first row and start the table */
$row = mysql_fetch_assoc ($result);
echo "<TABLE border=1>\n";
echo "</TR>\n";
foreach ($row as $heading=>$column) {
if ($heading != 'id') { //don't create a column for ID!
echo "<TD><b>";
if (in_array ($heading, $allowed_order)) {
echo "<a href=\"{$_SERVER['PHP_SELF']}?order=$heading&keyword=$query_text\">$heading</a>";
} else {
echo $heading;
}
echo "</b></TD>\n";
}
}
echo "</TR>\n";
/* reset the $result set back to the first row and
* display the data */
mysql_data_seek ($result, 0);
while ($row = mysql_fetch_assoc ($result)) {
echo "<tr>\n";
printf("<td><a href='http://embs-group.com/%s,%s'>%s</a></td>", $row['id'], str_replace(" ", "_", $row['name']), $row['name']);
$nombres_publisher = "SELECT t.nazwa AS nazwa FROM baza_obiektow_inne as t WHERE t.id=u.organizer_id";
printf("<td>%s</td>", $row['organizer_id']);
printf("<td>%s</td>", $row['no_pages']);
printf("<td>%s</td>", $row['publication_date']);
printf("<td>%s</td>", $row['price']);
printf("<td>%s</td>", $row['currency']);
echo "</tr>\n";
}
echo "</TABLE>\n";
}
ASKER
ASKER
mysql_data_seek ($result, 0);
while ($row = mysql_fetch_assoc ($result)) {
//get the publisher name
$organizerSql = mysql_query(SELECT nazwa FROM baza_obiektow_inne WHERE id=" . $row['organizer_id'] . " LIMIT 1");
$organizer = mysql_fetch_assoc($organizerSql);
echo "<tr>\n";
printf("<td><a href='http://embs-group.com/%s,%s'>%s</a></td>", $row['id'], str_replace(" ", "_", $row['name']), $row['name']);
printf("<td>%s</td>", $organizer['nazwa']);
printf("<td>%s</td>", $row['no_pages']);
printf("<td>%s</td>", $row['publication_date']);
printf("<td>%s</td>", $row['price']);
printf("<td>%s</td>", $row['currency']);
echo "</tr>\n";
}
$organizerSql = mysql_query(SELECT nazwa FROM baza_obiektow_inne WHERE id=" . $row['organizer_id'] . " LIMIT 1");
$tables = 'reports baza_obiektow_inne';
$organizerSql = mysql_query("SELECT nazwa FROM baza_obiektow_inne WHERE id=" . $row['organizer_id'] . " LIMIT 1");
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY