View Single Post
Old 20-08-2009, 17:19   #97
handyman
Permanently Banned
 
Join Date: Jun 2003
Location: Nr Carnforth
Age: 49
Services: M6 Keele
Posts: 5,462
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
handyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny starhandyman has a nice shiny star
Send a message via MSN to handyman
Re: Programming Challenges?

This may be a good place to ask this question which is probably too simples to have a thread of it's very own. Working on upgrading our current flat db to a more complex relational db in order to speed things up both in use and data entry. This bit of code is the index of dates.
I have 2 tables - courses and dates and each course can be associated with many dates.

This went well till a 4th date was added now I get an error.
Quote:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 9 in /home/purple/public_html/test/date_index.php on line 24

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 9 in /home/purple/public_html/test/date_index.php on line 25

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 9 in /home/purple/public_html/test/date_index.php on line 26
Start Date: 22/08/09
Course:
As I understand my code it gets an array of the dates and for each one it uses the course_id to get the course_name from the courses db.

Can anyone explain what I'm doing wrong?

Code:
<?php
include("menu.php");
include("connect.php");
$query="SELECT * FROM date ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
if ($num > 0 ) {
$i=0;
while ($i < $num) {
$date_start = mysql_result($result,$i,"date_start");
$course_id = mysql_result($result,$i,"course_id");
$id = mysql_result($result,$i,"id");
$date = date("d/m/y",strtotime($date_start));
include("connect.php");
$query2="SELECT * FROM course WHERE (`id`='$course_id') ";
$result2=mysql_query($query2);
$num2 = mysql_num_rows ($result2);
mysql_close();
$i2=0;
$code = mysql_result($result2,$i2,"code");
$name = mysql_result($result2,$i2,"name");
$id = mysql_result($result2,$i2,"id");
echo "<b>Start Date:</b> $date<br>";
echo "<b>Course:</b> $name<br>";
echo "<a href=\"date_update.php?id=$id\">Update Date</a> - <a href=\"date_delete.php?id=$id\">Delete Date</a>";
echo "<br><br>";
++$i; } } else { echo "The database is empty"; }?>
The Error is
handyman is offline   Reply With Quote