Jump to content

$row[] echo help


herghost

Recommended Posts

Hi all,

 

I have a page which simply pulls info from a database by id:

<?php
include ('connect.php');
$id = $_GET['id'];

		$query = mysql_query("SELECT * FROM JOBS WHERE id=$id");
		if (!$query) {
    		echo "Could not run query: " . mysql_error();
    		exit;
}
		$row = mysql_fetch_row($query);
		{
			echo "<body><h3>" . $row[1]. "</h3>";
			echo "<h4>" . $row[2] . "</h4>";
			echo "<h4>" . $row[3] . "</h4>";
			echo "<h5>Duties & Responsibilities:</h5><ul>";
			echo "<li><strong>" . $row[4] . "</strong>" . $row[5] . "</li>";
			echo "<li><strong>" . $row[6] . "</strong>" . $row[7] . "</li>";
			echo "<li><strong>" . $row[8] . "</strong>" . $row[9] . "</li>";
			echo "<li><strong>" . $row[10] . "</strong>" . $row[11] . "</li>";
			}
		?>

 

However in some cases the rows in the database may only contain data upto row 6 for example, how would I go about coding this so that it only displays rows that exist. If row 6 exists then 7 always will too as the information is connected. I am manually added this stuff into phpmyadmin as I do not need a form as once it is complete then it will not need to be added to.

 

Also row 8 and 9 may contain data but 6 and 7 may not

 

Many Thanks

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/215802-row-echo-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.