0

I have a php page that recalls data from an SQL table, and then displays them. I am trying to create a popup page to view tables related to a piece of data in the table(normalized database). I am having trouble figuring out how to do this. my current php table display is where $result is a mysqli query array

while($row = mysqli_fetch_array($result)) {
    echo '<tr>';
    echo "<td style='border:1px solid black;'>{$row['first_name']}</td>";
    echo "<td style='border:1px solid black;'>{$row['last_name']}</td>";
    echo "<td style='border:1px solid black;'>{$row['grade']}</td>";
    echo "<td style='border:1px solid black;'>{$row['gpaP']}</td>";
    echo "<td style='border:1px solid black;'>{$row['AGP']}</td>";
    echo "<td style='border:1px solid black;'>{$row['rigorP']}</td>";
    echo "<td style='border:1px solid black;'>{$row['APP']}</td>";
    echo "<td style='border:1px solid black;'>{$row['formID']}</td>";
    echo "<td style='border:1px solid black;'>{$row['total']}</td>"; 
    echo "<td style='border:1px solid black;'>{$row['date']}</td>";
    echo "<td style='border:1px solid black;'>{$row['IP']}</td>";
    echo '</tr>';
}

and

echo "<td style='border:1px solid black;'>{$row['formID']}</td>";

is what I need to change into a hotlink for a popup box. The popup's href should be "activities.php?form_id={$formID}" but I can't figure out a way to do this while dealing with all the collisions with the php and everything. What i was trying to do was making a link like

echo "<td style='border:1px solid black;'><a href=\"javascript:win1()\">asdfasd<a/></td>";

and then creating a javascript function like

<script language="JavaScript">
function win1() {
    window.open("activities.php?form_ID={$formID}","Window1","menubar=no,width=460,height=360,toolbar=no");
}
</script>

but this does not work because the $formID variable isnt getting loaded for some reason. If i try to get the variable from activities.php like

$getvar = $_GET['form_ID'];

and then

echo $getvar;

it displays nothing.. Someone please help me, I think my head is going to burst..

2 Answers 2

1

Try to change your function to

function win1(formID) {
    window.open("activities.php?form_ID="+formID,"Window1","menubar=no,width=460,height=360,toolbar=no");
}

and your PHP to

echo "<td style='border:1px solid black;'><a href=\"javascript:win1($formID)\">asdfasd<a/></td>";
Sign up to request clarification or add additional context in comments.

4 Comments

after i GET the variable in activities.php the echo is displaying "undefined"
how are you getting your formID? Maybe it should be win1($row['formID']
Yes! Check your browser [inspect element] and check the generated href value
IT WORKS OH YES THANK YOU SO MUCH! this was keeping me crazy for the whole day... If i could give you 10000 points i would.. THank you so much..
0

You can use inside the while:

echo "<td style='border:1px solid black;'><a href=\"javascript:win1('{$row['formID']}')\">asdfasd<a/></td>";

and function outside that while:

<script language="JavaScript">
function win1(frmid) {
    window.open("activities.php?form_ID="+frmid,"Window1","menubar=no,width=460,height=360,toolbar=no");
}
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.