Jump to content


Photo

Help with using varaibles to retrieve data from...


  • Please log in to reply
No replies to this topic

#1 Wes1890

Wes1890
  • Members
  • PipPipPip
  • Advanced Member
  • 242 posts

Posted 02 November 2005 - 06:12 AM

First off, here is my code:

<?php
// Connect
include("connect.php");

// Make the DB info into variables
$getnews = mysql_query("SELECT * FROM news ORDER BY news_id DESC"); }

// Set a function for easier reading down below 
function get_uidlink()
{
  $getuid = mysql_query("SELECT * FROM members WHERE username='".$user."'") or die ("Error: I need to talk to kylah more");
  $trowuid = mysql_fetch_array($getuid);
}

// Display the news
while($r=mysql_fetch_array($getnews))
{
  extract($r);
  $title = stripslashes($title);
  $message = stripslashes($message);
  get_uidlink();
    echo "<TABLE cellSpacing=0 cellPadding=4 width='100%' align=center>
  <TBODY>
    <TR>
    <TD class=memberbar><b>$title</b><br><i>Posted by </i><b><a href='members.php?mem_id=$member_id>$user</a></b><i> on </i><b>$date</b> at </i><b>$time</b></td>
    </TR>
    <TR>
    <TD class=newsmessage>$message</td>
    </TR>
  </TBODY>
  </TABLE><br>";
}

?>


Note the bold part...

That code displays a new section for each row of news is in the database.
And in the row of news, it has the news article creator's name, which is Wes (me).

I'm wanting to take that name "Wes" and get it's member id number (which is #1) and i want it to link to the members.php page where it will show the profile information for Wes...

But the username will not always be "Wes", so it needs to be selected inside the WHILE loop... I hope i'm making sence to ya'll phpFreaks...

Anyways, help would be awesome
AND THEN GOD HIMSELF BESTOWED HIS HAND UPON PHPFREAKS...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users