In message <[EMAIL PROTECTED]>,
Prinze Adam <[EMAIL PROTECTED]> writes
> Hello Guys,
>
> I have 2 MYSQL tables. The first one is containing user_ID and the
>second one is containing author_ID.
>I want to list and display up to 15 author_IDs at the same time, and whenever
>author_ID and user_ID are matching, the author_ID will be bolded.
> I have written some code myself, but what I have now is only displaying 1
>author_ID instead of 15.
> Does anybody know how to work this out with .php?
>
> <?
>include("password.php");
>mysql_connect(localhost,$username,$password);
>@mysql_select_db($database) or die( "Unable to select database");
>$query="select * from AUTHORS DESC LIMIT 15";
>$result=mysql_query($query);
>$num=mysql_numrows($result);
>mysql_close();
> $i=0;
>while ($i < $num) {
You don't need to figure out how many rows are returned, see later.
>$id=mysql_result($result,$i,"id");
>$name_U=mysql_result($result,$i,"user_name");
>
> //-----------------------------//
>//include("password.php"); u have already included this on the top
>mysql_connect(localhost,$username,$password);
You already connected at the top, as well...
>@mysql_select_db($database) or die( "this server is dying");
>$query="SELECT * FROM REGISTERED WHERE ='$name_U'";
The method used will be different, depending on which version of MySQL
you are using, because you could use a Subquery, if you version is >4.1
$query="SELECT author_ID, (SELECT COUNT(*) FROM users WHERE
user_ID=authorID) AS match FROM authors";
>$result=mysql_query($query);
while (list($authorID, $matched) = mysql_fetch_array($result)) {
if ($matched) {
echo "<b>$authorID</b><br>";
}else{
echo "$authorID<br>";
}
}
>$num1=mysql_numrows($result);
>mysql_close();
MySQL will close when the page has finished outputting.
* DEFINITELY untested <G>
--
Pete Clark
Never miss a lead again, receive SMS Texts from your website
Make money by providing the service
http://www.hotcosta.com/sms.php
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/