Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Task 6B-1
March 18, 2008 08:00AM
Done
Re: Task 6B-1
April 02, 2008 06:40AM
Done!
Re: Task 6B-1
April 18, 2008 01:16PM
done
JwV
Re: Task 6B-1
April 29, 2008 09:05AM
Done. I enjoyed the mysql chapter. Now to apply everything in the project.
JwV
Re: Task 6B-1
April 29, 2008 11:45AM
Hi there

I wrote the following script to join the subject and title tables. Just want to know if this the correct method to use. Also how would I display a field from two different tables who have the same name. (eg : Sub_id). I used the indexed method for the one field in this program. Would this be the only way to display the value. I tried echo $row[subject.sub_id]; but this did not seem to work.



<?php
$title = "Table Records";
include("header.php"winking smiley;
//link to mysql
$link_id = mysql_connect('localhost', 'root', ''winking smiley;
if ($link_id)
echo "Connected to the MySQL server successfully <br>";
else
die ("Connection to the MySQL server was unsuccessful"winking smiley;
mysql_select_db("bookstore_db"winking smiley;

$res_title = mysql_list_fields("bookstore_db", "titles"winking smiley;
$res_subject = mysql_list_fields("bookstore_db", "Subject"winking smiley;

echo "<h3>The subject and title databases contains the following records:</h3>";
echo "<table border='1' width='1100' cellspacing = '0' cellpadding='0'>";
echo "<tr>";
for ($i=0; $i < mysql_num_fields($res_title); $i++) {
echo "<th width='10%'>" . mysql_field_name($res_title, $i) . "</th>";
}
for ($i=0; $i < mysql_num_fields($res_subject); $i++) {
echo "<th width='10%'>" . mysql_field_name($res_subject, $i) . "</th>";
}
echo "</tr>";

$result = mysql_query ("select * from titles, subject where titles.sub_id = subject.sub_id order by isbn"winking smiley;
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td width='8%'>";
echo $row['ISBN'];
echo "</td>";
echo "<td width='30%'>";
echo $row['Title'];
echo "</td>";
echo "<td width='8%'>";
echo $row['Price'];
echo "</td>";
echo "<td width='10%'>";
echo $row['Pub_date'];
echo "</td>";
echo "<td width='6%'>";
echo $row['Auth_id'];
echo "</td>";
echo "<td width='5%'>";
echo $row['Sub_id'];
echo "</td>";
echo "<td width='5%'>";
echo $row[6];
echo "</td>";
echo "<td width='35%'>";
echo $row['Subject'];
echo "</td>";
echo "</tr>";
}
echo "</table>";

include ("footer.php"winking smiley;
?>
Re: Task 6B-1
May 13, 2008 01:50PM
Done
Anonymous User
Re: Task 6B-1
May 25, 2008 06:11PM
Completed!
avatar
Mac
Re: Task 6B-1
May 26, 2008 07:45AM
If you have 2 tables with same field names, then use aliases in your select query. Go google on that smiling smiley
Re: Task 6B-1
June 03, 2008 08:29AM
I have completed
Sorry, only registered users may post in this forum.

Click here to login