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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.