1

contID from my db just gives a number, that number i want to put on the end of a varible, tried it like this but it gives a blank page

if i take the

"" . $row['contID'] . ""

out its fine and the page loads fine, so i know its the wrong way to do it but i cant think of how to do it any other way, heres the code...

$object = new ConnectToDB();
$result = $object->getMarks($user,$ksGet);

foreach($result as $row){

    $marks"" . $row['contID'] . "" = "" . $row['mark'] . "/5";
}

the result from the db will give 7 rows the contID will be a number between 1 and 7

0

1 Answer 1

2

an array is a much smarter idea than variable variables

$marks=array();
foreach($result as $row){

    $marks[{$row['contID']}]  =  $row['mark'] . "/5";
}
Sign up to request clarification or add additional context in comments.

2 Comments

how do i echo that out, I'm guessing $marks[1] etc ?
don't guess, just try it

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.