My first php program
I am using ADODB "http://adodb.sourceforge.net/" to get $results.
i then use
foreach ($results as result) {
<td><?php echo $result['value1']; ?></td>
<td><?php echo $result['value2']; ?></td>
}
now i need to parse a $result['value1'] in a $_SESSION['value1'] that
needs to be used in another select statement.
i cant use <td><?php $_SESSION['value1'] = $result['value1'];
?></td>
because that just stores the last "value1" into $_SESSION.
and the same goes for <td><?php $result[0]['value1']; ?></td>
any ideas im going crazy here :(
Re: My first php program
spacerat wrote:
> I am using ADODB "http://adodb.sourceforge.net/" to get $results.
>
> i then use
>
> foreach ($results as result) {
>
> <td><?php echo $result['value1']; ?></td>
> <td><?php echo $result['value2']; ?></td>
>
> }
>
> now i need to parse a $result['value1'] in a $_SESSION['value1'] that
> needs to be used in another select statement.
>
> i cant use <td><?php $_SESSION['value1'] = $result['value1'];
> ?></td>
> because that just stores the last "value1" into $_SESSION.
> and the same goes for <td><?php $result[0]['value1']; ?></td>
>
> any ideas im going crazy here :(
You're not making a great deal of sense here.
First of all the "foreach ($results as result) {" would not work as it
should be "foreach ($results as $result) {"
Next the code would not output "<td>" or "</td>" as these are within
part of the php parsing (assuming that the foreach is part of it).
Leading on from that the "<?php" after the "<td>" shouldn't be there,
as it is already being executed by php.
Finally you say " i cant use <td><?php $_SESSION['value1'] =
$result['value1']; ?></td> because that just stores the last "value1"
into $_SESSION."
But you only said that you wanted to store "a" $result['value1'] and
the last one is as much a $result['value1'] as any other one. You then
go on to say that it is the same for $result[0]['value1']. The only way
that this can be true is if there is only one result row.
So how about thinking about this and telling us precisely what you want
to achieve?
Re: My first php program
forgive me for my ambuguity
by actual code is as follows
======START=====
<?php
require_once ('./includes/site_globals.inc.php');
$subject = $_SESSION['Subject'];
$year = $_SESSION['Year'];
$semester = $_SESSION['Semester'];
//Get all classes for a given subject , in an occurance of a
year/semester
$results = $db->GetAll("SELECT *
FROM classcode c
WHERE subject = '$subject' AND year = '$year' AND semester =
'$semester'");
?>
<?php if ( !$results ) { ?>
<?php echo "There are currently no subjects to allocate for"; ?>
<?php } else { ?>
<link href="css/ames.css" rel="stylesheet" type="text/css" />
<table border="0" align="center">
<tr>
<td class="tableheader">ClassCode</td>
<td class="tableheader">Class</td>
</tr>
<form name="update_allocations" action="allocation_update_form.php"
method="post">
<div>
<?php foreach ($results as $result) { ?>
<tr>
<td class="shade"><?php echo $result['classcode']; ?></td>
<td class="shade"><?php echo $result['activity']; ?></td>
<td>
<input type="submit" name="classcode" value="<?php echo
$result['classcode']; ?>">
</td>
<?php } ?>
</tr>
</div>
</form>
</table>
<? } ?>
======END=====
this dumps it into "allocation_update_form.php"
which the main query is.
$results = $db->GetAll("SELECT *
FROM classlist c
WHERE c.subject = '$subject' AND c.year = '$year' AND c.semester =
'autumn'
AND classcode = '$classcode'");
its dumping the data ok but the problem i am is that $classcode is
always the same number. when i click on the 'submit' button.
Re: My first php program
umm sorry.
somehow i managed to fix the bugger.