Hi,
I have this code called comp_initial.php as shown beloow:
[code=php]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>The Blog Warehouse</title>
<meta http-equiv=”content-type”
content=”text/html; charset=iso-8859-1″ />
</head>
<body>
<h1>Companies in the Blogosphere (Boolean search)</h1>
<?php
$dbcnx = @mysql_connect(‘localhost’, ‘root’, ‘password’);
if (!$dbcnx) {
exit(‘<p>Unable to connect to the database server at this time.</p>’);
}
// Select the blog database
if (!@mysql_select_db(‘ijob’)) {
exit(‘<p>Unable to locate the blog collection database at this time.</p>’);
}
?>
<?php
$a_name_qeury = “select comp_name from company_list where comp_name like ‘a%'”;
$a_name_result = @mysql_query($a_name_qeury );
if(!$a_name_result) {
exit (‘<p>Error retrieving blog entries from database!<br />’.
‘Error: ‘.mysql_error(). ‘</p>’);
}
while ($a_name_output =mysql_fetch_array($a_name_result)){
$a_name =$a_name_output[comp_name];
$a_qeury = “select id, content from blog_entry where content like “;
$a_qeury = $a_qeury . ‘”%’;
$a_qeury = $a_qeury . $a_name;
$a_qeury = $a_qeury . ‘%”‘;
$a_result = @mysql_query($a_qeury);
if(!$a_result) {
exit (‘<p>Error retrieving blog entries from database!<br />’.
‘Error: ‘.mysql_error(). ‘</p>’);
}
$a_output = mysql_fetch_array($a_result);
if ($a_output != “”) {
$id = $a_output[id];
echo “<a href = ‘comp_name.php?id = $id’>A</a>”;
}
}
?>
</body>
</html>
‘comp_name.php is the file to display the names retrieved from MySQL table, using id as the condition. ‘comp_name.php is shown as below:
[code=php]
<?php
$dbcnx = @mysql_connect(‘localhost’, ‘root’, ‘password’);
if (!$dbcnx) {
exit(‘<p>Unable to connect to the database server at this time.</p>’);
}
if (!@mysql_select_db(‘ijob’)) {
exit(‘<p>Unable to locate the blog collection database at this time.</p>’);
}
?>
<?php
$id =$_GET[‘id’];
$select = “SELECT DISTINCT title, id, publish_date from blog_entry where id=’$id’ GROUP BY title order by publish_date”;
$retrieve = @mysql_query($select);
if(!$retrieve) {
exit (‘<p>Error retrieving blog entries from database!<br />’.
‘Error: ‘.mysql_error(). ‘</p>’);
}
while ($result = mysql_fetch_array($retrieve)) {
if ($result != “”) {
echo “<a href = ‘comp_content.php?id = $id ‘>$result[title]</a>”;
echo “$result[publish_date]”;
}
}
?>
However, there are some bugs in the codes. When A is clicked, nothing comes out. Could anyone help? ?
Thanks a lot ?