SQL query two row of a table in a bidding system

1

I would like to know how I could add to a query, that it also see data from another row of the same table, I have the "USERS" TABLE with rows ID, USER, WEB

<?php

$resusuario=mysql_query("SELECT * FROM usuario WHERE usuario = 
'".$fs['usuario']."' limit 1");
$fsu=mysql_fetch_array($resusuario);
$email_id  = $fsu['email'];
$email = md5(strtolower(trim($email_id)));
$gravurl = "https://secure.gravatar.com/avatar/$email?d=&s=30";

<div class="col-md-2 col-md-push-0"  style="padding: 10px;">
    <img src="<?=$gravurl?>"  border="0" alt="">
    <a href="#" title="<?php echo 
    $fs['usuario'];?>"><?php echo $fs['usuario'];?></a>

    </div>

What I want is that when you click on the username, take the WEB address assigned to it in the table. Thank you in advance for the collaboration.

    
asked by Frodo 15.10.2018 в 03:25
source

2 answers

1

I would do it with a view, or a stored procedure,
could you please be clearer by generating the type of table you have and the type of result you want on this page, if not at least do an approximate and already be able to collaborate you.
link

What BD engine are you in?

DELIMITER $$
DROP VIEW IF EXISTS 'tbl3'$$
USE 'EXAPLE_BD'$$

    CREATE VIEW 'tbl3' AS
    select id from tbl
    union 
    select texto from tbl;
 DELIMITER ;

select * from tbl3
    
answered by 15.10.2018 в 03:29
0

According to what you say, the url of the web page is in the same table, you just have to put in the href the url, as you have done with the user

<div class="col-md-2 col-md-push-0"  style="padding: 10px;">
    <img src="<?=$gravurl?>"  border="0" alt="">
    <a href="<?php echo $fs['urlWeb']; ?>" title="<?php echo 
    $fs['usuario'];?>"><?php echo $fs['usuario'];?></a>

    </div>
    
answered by 15.10.2018 в 06:08