scottyd Posted September 2, 2008 Share Posted September 2, 2008 Hi there- Am I still young to PHP and MySQL development, so please bear with my questions. I am trying to develop a page that when a link is clicked, a jquery window opens up and displays the content dynamically. The links and the content are being pulled dynamically from a mysql DB. Everything was going fine until I hit a sang with how a different link with a different id will be able to pull up the same content. For example, links A, B, and C all have an id of 1,2 and 3 (A=1, B=2, and C=3) They all are in the same table in MySQL. I put in a link of D, but I need that to point to A, so it would be like D=1 and link A=1 as well, but D gets assigned an ID of 4 when inserting data into the table. I am not too sure on how I need to structure this so that everything can "match up" across the board. I am using PHP to pull out the info like so: <?php //open DB connection include 'dbconn.php'; $sql = "select * from tbltest"; $result = mysql_query($sql,$conn); while ($row = mysql_fetch_array($result)){ $id = $row['id']; $link = $row['issue']; echo <<<END <tr> <td align="center"><a href ="testdisplay.php?id=$id''keepThis=true&TB_iframe=true&height=250&width=400'" title="$id - $link" class="thickbox">$link</td> </tr> END; } ?> and then the other page as follows: <?php //open DB connection include 'dbconn.php'; $sql = "select * from tbltest where id = '$_GET[id]'"; //print $sql; $result = mysql_query($sql,$conn); while ($row = mysql_fetch_array($result)){ $id = $row['id']; $firstname = $row['firstname']; echo <<<END <tr> <tr> <td align="center">$id</td> <td align="center">$firstname</td> </tr> END; } ?> As you can probably see, I am try to post out users names based on an "Issue" that is assigned to them, but if there are different issues, I need to have it match up to their same name. I guess I am also trying to make it so I am not have to have multiple entries within my DB as well, nor create a bunch of rows within the DB strucutre as well (i.e. ID FIRSTNAME ISSUE 1 Joe Email 2 Jimmy Images 3 Joe Computers 4 Joe Phones ) Just sucks cause the data that was given to me wasn't in that format. It's all in anchors on an HTML page, hence the reason why different links go to the same table row, and why I want to do this dynamically so that if something changes I am not going through a sea of HTML code. Any ideas would be great. I am not too sure how I am going to be able to do this without really doing a lot of CnP and adding a ton of table rows. Quote Link to comment Share on other sites More sharing options...
zq29 Posted September 3, 2008 Share Posted September 3, 2008 You need three tables, rather than one. person id, name issue id, name person_issue id, person, issue This way, you only create each issue once, each person once and link issues to people with the person_issue table. Quote Link to comment Share on other sites More sharing options...
scottyd Posted September 3, 2008 Author Share Posted September 3, 2008 That's kinda what I was thinking when I went to bed last night (yes, the thought of PHP programming makes me go to sleep..). I was thinking of like maybe even just using like a join when trying to display the info, but I'll try to hammer something out today. THANKS! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.