
August 13th, 2002, 10:18 AM
|
|
|
|
Join Date: Apr 2007
Location: Sweden
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Passing data to an array
I am wanting to define a result from a select as an array but am not sure how to do it. Here is the code I have so far:
php Code:
Original
- php Code |
|
|
|
$sql="SELECT count(*) as 'number' FROM ttable, tnotes as ant WHERE datename(mm, dtindate) = datename(mm, ant.dtDatum) and datepart (yy, dtindatem) = $ar and ttable.iId = ant.iID and ant.chcomment like 'This is great' group by datepart(mm, dtindate) order by 'Number'"; $result = odbc_exec($conn_id,$sql); while($a=odbc_fetch_array($result)) { //print("Comment: " . $a["antal"] . "Month:" . $a["Number"] . "<br>n"); } odbc_fetch_array($result,$row); echo $row['Number']. "bla bla"; odbc_close($conn_id); } include ("jpgraph.php"); include ("jpgraph_line.php"); $ydata = $a;
OK what I am doing is getting a result (Number) which is a series och numbers, e.g 123,434,565
I want these to be the data in the array $ydata
eg: $ydata = (123,434,565)
Really appreciate any help you'all can give me. First time I am using arrays in a script.....
Thanks
-------------------
Several hours later!
Now I have tried this:
php Code:
Original
- php Code |
|
|
|
$sql="SELECT count(*) as 'antal',datepart(mm,dtinlagddatum) as 'Nummer' FROM tPlatsannons, tPlatsannonsDaganteckning as ant WHERE datename(mm, dtInlagddatum) = datename(mm, ant.dtDatum) and datepart (yy, dtinlagddatum) = $ar and tPlatsannons.iPlatsannonsid = ant.iPlatsannonsID and ant.chKommentar like 'Granskning pågår' group by datepart(mm, dtinlagddatum) order by 'Nummer'"; $result = odbc_exec($conn_id,$sql); if ($myrow=odbc_fetch_array($result)) { do { $datay[] = $myrow["antal"]; }while ($myrow=odbc_fetch_array($result)); }
But still get no output for $datay
-----------
If at first you don't succeed, try, try again 
|