Jump to content

Help with using varaibles to retrieve data from...


Wes1890

Recommended Posts

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

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.