Jump to content

DISTINCT Lookup and Display


fizzzgigg

Recommended Posts

I am getting a little frustrated, and I need some help. I've working on this all day (I am new... otherwise I'd fly through it). This is a simple problem I just can't seem to put a ' in the right spot or something...

 

Here's the gist. In file myphotos.php is the following:

<?PHP
include('functions.php');
$link
$title = 'Light Graspers Certification';
$linktent = '<div class="titler">Photo Review</div><div class="contentm">'.$data[index].'</div>';
$excess = '<div class="titlerex">Testimonials</div><div class="contentmex">'.$displayoptions.'</div>';
echo getphoto($title, $linktent, $excess);
?>

 

Now my goal is under $displayoptions the following will happen.

 

SELECT DISTINCT name FROM homework WHERE uid='$loggedin' ORDER BY id";

With proper code I should see a distinct list of all the "name" rows. The user clicks on it to be directed to just those rows... etc...

 

Here is was some old code I tried manipulating to get the same result... but I couldn't seem to get it to work. Of course I only need one column in my new code.

Any help would be a appreciated.

 

Adam

$columns = 5;
//change the query to get another field from the database
$query = "SELECT DISTINCT city,state FROM church WHERE state='$state' ORDER BY city";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
$rows = ceil($num_rows / $columns);
while($row = mysql_fetch_array($result)) {
$data[] = $row['city'];
//store the other field into an array

}
for($i = 0; $i < $rows; $i++) {
{
echo "<tr valign=bottom>";
echo "<td bgcolor=#2172A1 colspan=10><img src=img/blank.gif width=1 height=1></td>";
echo "</tr>";
}
echo "<TR valign=center>";
for($j = 0; $j < $columns; $j++) {
if(isset($data[$i + ($j * $rows)])) {
echo "<td class=tabval><b><a href='findnew.php?state=".$state."&city=" . $data[$i + ($j * $rows)] . "'>" . $data[$i + ($j * $rows)] . "</a></b></td>";
}
}
echo "</TR>";
}
echo "<tr valign=bottom>";
    echo "<td bgcolor=#2172A1 colspan=10><img src=img/blank.gif width=1 height=8></td>";
    echo "</tr>";

echo "$state represents $num_rows3 \n of our $num_rows2 churches\n that we serve.	";

}

Link to comment
Share on other sites

Oh sorry I thought I included that. Globalfunction is beneath this as well...

function getphoto($title, $content, $excess = null, $excess2= "") {
$data = globaldata();
$excess = ($excess==null)?$data[sidebar]:$excess;
global $loggedin;
$admin = isadmin($_COOKIE[sid])?'<a href="admin.php">Admin Link</a><br />':'';
$admin2 = isadmin($_COOKIE[sid])?' id="bodi" '.$excess2:'';
$teacher = isteacher($_COOKIE[sid])?'<a href="teacher.php">Teacher Link</a><br />':'';
$teacher2 = isteacher($_COOKIE[sid])?' id="bodi" '.$excess2:'';
$welcome = ($loggedin == false)? 'Welcome, Guest, why not <a href="register.php">Register</a>?':'Welcome Back, '.$loggedin.'!';
$exlinks = ($loggedin == false)? '<a class="nav" href="login.php">Login</a>'.
	'<a class="nav" href="register.php">Register</a>':''.
	'<a class="nav" href="portal.php">Purchased</a>'.
	'<a class="nav" href="profile.php">Your Profile</a>'.
	'<a class="nav" href="login.php?logout=true">Logout</a>';
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>'.$title.' - '.$data[name].'</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="'.$data[description].'" />
<meta name="keywords" content="'.$data[keywords].'" />
<script src="scripts.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="'.$data[favicon].'" rel="shortcut icon" type="image/x-icon" />
<link href="js/lytebox.css" rel="stylesheet" type="text/css" />
<script src="js/lytebox.js" type="text/javascript"></script>
</head>
<body'.$admin2.'>
<body'.$teacher2.'>
<div class="main">
	<div class="toplinks">
		<a class="toplinks" href="index.php">About Us</a>   
		<a class="toplinks" href="faq.php">FAQ</a>   
		<a class="toplinks" href="contact.php">Contact Us</a>   
		<a class="toplinks" href="login.php">Login</a>   
		<a class="toplinks" href="register.php">Register</a>
	</div>
	<div class="logo">
		<!--<a href="index.php" class="logo" alt="'.$data[name].'"><span>'.$data[name].'</span></a>-->
		<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="885" height="94" id="Untitled-1" align="middle">
		<param name="allowScriptAccess" value="sameDomain" />
		<param name="allowFullScreen" value="false" />
		<param name="movie" value="swf/theme.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="swf/theme.swf" quality="high" bgcolor="#ffffff" width="885" height="94" name="Untitled-1" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
		</object>
	</div>
	<div class="links">
		<a class="nav" href="index.php">Home</a>
		<a class="nav" href="myphotos.php">My Photos</a>
		<a class="nav" href="search.php">Tutorials</a>
		'.$exlinks.'
	</div>
	<div class="content">
		<div class="welcome">
			'.$welcome.'
		</div>
		<div class="mainc">
			'.$content.'
		</div><div class="addc">
			'.$excess.'
		</div>
	</div>
	<div class="copyright">
		'.$admin.'
		'.$teacher.'
		'.$data[copyright].'
	</div>
</div><!--
<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
	try {
	var pageTracker = _gat._getTracker("UA-8937404-2");
	pageTracker._trackPageview();
	} catch(err) {}
</script>-->
</body>
</html>';
}

 

here is is global function:

 

function globaldata() {
$query = mysql_query("SELECT * FROM `global`");
while($row = mysql_fetch_assoc($query)) {
	$data[$row[name]] = base64_decode($row[data]);
}
return $data;
}

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.