I am trying to display a list of links to a user but i dont want a link to be displayed if they have previously clicked it, im using the following code to display the links in a table: <?PHP session_start(); if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) { header('Location: login.php'); exit; } echo "Welcome "; echo $_SESSION['user_logged']; include("sql.php"); $result = mysql_query("SELECT * FROM tracking"); echo "<table align=\"center\" border=\"0\">"; while ($rows = mysql_fetch_row($result)) { echo "<tr><td><a href='testframe1.php?id=$rows[1]'>$rows[3]</a></td></tr>"; } echo "</table>"; ?> PHP: When a user clicks a link it updates a mySQL table with the links ID and the user who clicked it but i cant figure out how to stop links from being displayed if they are allready clicked by the user. Any help would be great cheers.
Thanks for the suggestion but that wont work as the two tables are seprate tables, one table holds the link information ie URL, URL title and the URL ID number while the other table holds the data on who has clicked the link ie URL ID and the users username, each time a different user clicks a link it ads a line to the later table with ID and username.
select url, url_title, url_id, clicked from tbl1 left join tbl2 on tbl2.id=tbl1.id where tbl2.clicked = 0
ok that got me a step closer but now its not displaying any links if there clicked or not i am using the following mySQL query $result = mysql_query("select * from tracking left join adstats on adstats.adcode=tracking.id where adstats.user !='toasty'"); PHP: however if i change it so its where adstats.user ='toasty' PHP: it will display the link that toasty has clicked instead of displaying the link toasty hasnt clicked wich is not what im after.
well for one, let's not go select * let's get exactly what we want. and secondly, do a describe adstats, and a describe tracking for me. and in order for this to work, the tables need to be synced with one another. meaning that at least one column in each has to match. eg: tbl1.id = tbl2.state_id... tbl1.id would be the same as tbl2.state_id
Here is the describe adstats: Field Type Null Key Default Extra id varchar(255) user text Code (markup): Here is the describe tracking: Field Type Null Key Default Extra url varchar(255) id varchar(255) count varchar(255) title varchar(255) Code (markup): And here is the MySQL query: $result = mysql_query("select tracking.url, tracking.id, tracking.count, tracking.title, adstats.id, adstats.user from tracking left join adstats on tracking.id=adstats.id where adstats.user !='toasty'"); PHP:
let's try this. if anything just send me the code and a db dump and i'll get it goin for ya. but try this first. select tracking.id as tid, adstats.id as aid, url, count, title, user from tracking left join adstats on adstats.id = tracking.id where adstats.user != 'toasty' Code (markup): from what i can tell you have your join syntax backwards. should be "left join tbl1 on tbl1.foo = tbl2.foo", not "left join tbl1 on tbl2.foo = tbl1.foo"