|
|||
|
I'm trying to output sessions "row 0" "row 1" etc and all I get is either a blank output or "Array"
This was working before I put the loop in. I think there's a problem with ['row '.$i] I've tried $row = "row "; $row = $row.$i - but that doesn't work either. Can anyone see where i'm going wrong? The php is - $query = " SELECT * FROM table ORDER BY RAND() LIMIT 1 "; for($i = 0; $i <= 2; $i++) { if($result = mysql_query($query)) { while( $output = mysql_fetch_row($result) ) { // create name and output to session $_SESSION ['row '.$i] = $output; } mysql_free_result($result); } } the output page is echo $_SESSION['row 0']; echo ' <br>'; echo $_SESSION['row 1']; echo ' <br>'; echo $_SESSION['row 2']; echo ' <br>'; I can't think of any other way of creating row 0, row 1 in the loop. Thanks in advance. Steve. |
|
|||
|
Hi Steve,
You get an array at the output page because the $output variable is an array of the columns you have in the table. If you want to use a certain column you need to use either $output[column-name] or better, in the output page put $row0 = $_SESSION['row 0']; echo $row0[column-name1].' '.$row0[column-name2]..... Claudiu |
|
|||
|
Ah yes, of course, I mised that.
Cheers mate, spent ages trying to suss it out. have changed the processing page to ~ for($i = 0; $i <= 2; $i++) { if($result = mysql_query($query)) { while( $row = mysql_fetch_row($result) ) { $output = $row[$i]; $_SESSION ['row '.$i] = $output; } // free results mysql_free_result($result); } } Works now. Thanks again. Steve |
![]() |
| Bookmarks |
| Webmaster Resources |
| • UK Web Hosting • UK WW SEO Tools • Free site submission • Web Directory |
| Advertisement |
|
| Site Of the Month |
![]() Nominate site of the month |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If you ever had this problem... | darkstar_tfd | General Webmaster Talk | 8 | 11-06-2007 08:43 AM |
| problem with Sessions | StevieB | General Webmaster Talk | 0 | 09-21-2007 02:57 PM |
| little problem | Bisje | Feedback (Don't holdback :) | 6 | 09-20-2007 12:40 PM |
| Problem! | smartu | iG Shop | 0 | 01-14-2004 05:41 AM |
| Problem | Funnydummy | iG Shop | 0 | 11-04-2003 12:10 PM |
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |