Jump to content

Structure Question


scottyd

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/122456-structure-question/
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/122456-structure-question/#findComment-632663
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.