Jump to content

[SOLVED] Drop down tables


thefollower

Recommended Posts

I have a table which i want to display infomation between rows like a dynamic drop down type of thing only not all fancy graphics just simple.. how ever i attempted it but it failed miserably! To get an idea of what i am trying to do here is an explaination:

 

imagine :

 

Report 1   - View
Report 2   - View

 

Now you want to view report 1

so itll be like:

 

Report 1 - View \/

[content]

[content]

[content]

[content]

Report 2  - View

 

To do this i used used a Get in the "View" carrying the ID then that GET is pull out during the while loop so its after each row but it didnt work as the content was displayed above the table completely...

 

This is what i got:


<?php
//row columns created earlier in script and the query etc

while($row = mysql_fetch_assoc($GetReports)){
$RecordID = $row['RecordID'];
$Info = $row['Log'];
$ReportedPlayer = $row['ReportedPlayer'];
$GetUserName = mysql_query("SELECT * FROM userregistration WHERE UserID='$ReportedPlayer'")
or die(mysql_error());
$UserNameRow = mysql_fetch_assoc($GetUserName);
$ReportedPlayer = $UserNameRow['Username'];
?>
<tr>
<td width="100"><center><font style="font-size:14px" color="#FFFFFF" face="Arial"><?=$ReportedPlayer?></center></font></td>
<td width="100"><center><font style="font-size:14px" color="#FFFFFF" face="Arial"><a href="pendingreports.php?view=<?=$RecordID?>" style="color:#FFFFFF">View</a></center></font></td>
</tr>
<?php
If(isset($_GET['view'])){
?>
<font style="font-size:13px" color="#FFFFFF" face="Arial">UserID: <?=$UserID?><br>
UserName: <?=$UserName?><br>
Money: <?=$Money?><br>
<br>
<a href="viewuerslogs.php?logs=<?=$UserID?>" style="color:#FFFFFFF">View user's logs</a><br>
<a href="viewusersmessages.php?messages=<?=$UserID?>" style="color:#FFFFFF">View user's messages</a><br>
<a href="Viewusersonsameip.php?ip=<?=$UserID?>" style="color:#FFFFFF">View user's on same IP</a></font></div>
<b><u>Player Report Infomation:</u></b>
<?=$Info?> 
<a href="closereport.php?report=<?=$RecordID?>" style="color:#FFFFFF">No Evidence</a><br>
<br>
<a href="secondopinion.php?report=<?=$RecordID?>" style="color:#FFFFFF">Get Second Opinion</a><br>
<br>
<a href="punishment.php?report=<?=$RecordID?>" style="color:#FFFFFF">Guilty</a></u></b></font></div>
<?
}
}
?>

Link to comment
Share on other sites

Well the logic looks right to me. My guess is that either the first loop doesn't print out a "ReportedPlayer" and it does print out the stuff after view so it looks like it is above it, but it is really above the second one, or There is some crazy html issue, but hardly ever would that cause content to be displayed in the wrong order. I still don't see a <table> tag, though. Is it above your php that you pasted?

 

I would look at the source and see if the html is printed out like you would expect. Even post the html source if you can't see what is wrong in it.

Link to comment
Share on other sites

heres the full table:

Hope you can help ! :)

 

<?php
<div id="bv_" style="position:absolute;left:160px;top:350px;width:150px;height:22px;z-index:1" align="center">
<table width="600" border="1" cellpadding="0" cellspacing="0">
<tr>
    <td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>User:</center></b></u></font></td>
    <td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Report ID:</center></b></u></font></td>
    </tr>
<?
while($row = mysql_fetch_assoc($GetReports)){
$RecordID = $row['RecordID'];
$Info = $row['Log'];
$ReportedPlayer = $row['ReportedPlayer'];
$GetUserName = mysql_query("SELECT * FROM userregistration WHERE UserID='$ReportedPlayer'")
or die(mysql_error());
$UserNameRow = mysql_fetch_assoc($GetUserName);
$ReportedPlayer = $UserNameRow['Username'];
?>
<tr>
<td width="100"><center><font style="font-size:14px" color="#FFFFFF" face="Arial"><?=$ReportedPlayer?></center></font></td>
<td width="100"><center><font style="font-size:14px" color="#FFFFFF" face="Arial"><a href="pendingreports.php?view=<?=$RecordID?>" style="color:#FFFFFF">View</a></center></font></td>
</tr>
<?
If(isset($_GET['view'])){
?>
<font style="font-size:13px" color="#FFFFFF" face="Arial">UserID: <?=$UserID?><br>
UserName: <?=$UserName?><br>
Money: <?=$Money?><br>
<br>
<a href="viewuerslogs.php?logs=<?=$UserID?>" style="color:#FFFFFFF">View user's logs</a><br>
<a href="viewusersmessages.php?messages=<?=$UserID?>" style="color:#FFFFFF">View user's messages</a><br>
<a href="Viewusersonsameip.php?ip=<?=$UserID?>" style="color:#FFFFFF">View user's on same IP</a></font></div>
<b><u>Player Report Infomation:</u></b>
<?=$Info?> 
<a href="closereport.php?report=<?=$RecordID?>" style="color:#FFFFFF">No Evidence</a><br>
<br>
<a href="secondopinion.php?report=<?=$RecordID?>" style="color:#FFFFFF">Get Second Opinion</a><br>
<br>
<a href="punishment.php?report=<?=$RecordID?>" style="color:#FFFFFF">Guilty</a></u></b></font></div>
<?
}
}
}
?>

Link to comment
Share on other sites

Well, I'vre read your posts a couple times and don't really understand the problem you are describing. It would be helpful if you posted a link to the page haing the problem. From what I can ascertain, this is NOT a php proble. It is a problem with the HTML you are creating from the PHP code. I would suggest taking the HTML output andsaving it is as a flat file. Then modify the HTML to get it working. Then you can modify the PHP to match.

 

But, I do see some issues:

 

1) You are using nested queries. I.e. you are doing a querie within a loop. This is horribly inefficient and creates a huge load on your server. As the data set gets larger you may run into timeout issues. You should write a single query to get all the data you need.

 

2) You are redefining the variable $ReportedPlayer twice in your loops to two different values. It should work, but it is bad practice.

 

3) You are suing PHP short tags. This is also bad practice because it is not always supported

 

4) Start using styles. The FONT tag has been deprecated for many years now.

Link to comment
Share on other sites

You should use java for this.

 

People turn java off and it causes problems.

 

The problem i have is this:

 

The last bit of html in the script is not appearing inbetween the rows, it's being echoed above the entire table rather than being displayed under the row that the user is viewing...

 

So it be like:

Row    -  View

 

When the person clicks view the info under the GET function will display below that row.. but "above" the rest of the rows in that table... so kinda like a drop down box like you get in javascript only not in graphical terms cos people kept turning javascript off and messing it about.

Link to comment
Share on other sites

1) You are using nested queries. I.e. you are doing a querie within a loop. This is horribly inefficient and creates a huge load on your server. As the data set gets larger you may run into timeout issues. You should write a single query to get all the data you need.

 

So would it still work if the query is outside the loop?

 

So in the while loop i should only need to have the fetch_assoc function ?

Link to comment
Share on other sites

You are adding information to a table not in a collumn or row. Just take out the </td> and </tr> right before the "If(isset($_GET['view'])){" and it should go into the same cell. If you wanted a new cell, use another <td> tag. When you want to end the table, use </table>

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.