Jump to content

Akshen

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Akshen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The input below works perfectly when inside the form I wish to submit, but I'd like to place it outside the <form> tags and use it to submit based on id/class to the seperate pages. Obviously the onChange needs to look something like "onChange=submit MyForm to location of value", how I do that in JS is the question. If anyone could shed some light on the issue, it'd be much appreciated! <?php echo "<select size=\"1\" onChange=\"this.form.action=this.options[this.selectedIndex].value;\"> <option>Submit to...</option> <option value=\"index.php?q=". $_SESSION['nav_sid'] ."&page=1\">Page1</option> <option value=\"index.php?q=". $_SESSION['nav_sid'] ."&page=2\">Page2</option> <option value=\"index.php?q=". $_SESSION['nav_sid'] ."&page=3\">Page3</option> </select> <form id=\"MyForm\"> <input type=\"text\" name=\"blah\" /> </form>"; ?>
  2. Ok, knowing barely anything about OOP before this post i've tried to do a bit of homework and it seems like I need to shove all my data into an array first? I've tried to find an example of tutorial on how to do this, or atleast a way to use this foreach loop but can't seem to find anything as I probably still dont know what I'm looking for. Is it even possible to use -> operators from mysql_fetch_object?
  3. <?php $result = mysql_query("SELECT * FROM example_table"); while ($rows = mysql_fetch_object($result)){ echo $rows->date; } Considering the above does work... How come: <?php $result = mysql_query("SELECT * FROM example_table"); while ($rows = mysql_fetch_object($result)){ foreach ($rows as $row){ echo $row->date; } } Doesn't work? I just get nothing back as soon as I use the foreach statement.
  4. Still no joy, although this does work... <?php $result = mysql_query("SELECT * FROM example_table"); while ($rows = mysql_fetch_object($result)){ echo $rows->date; } Seems to be a problem with the foreach?
  5. Thanks for the quick response ranjuvs, that's awesome. Ok so I tried the following... <?php $result = mysql_query("SELECT * FROM example_activites"); while ($rows = mysql_fetch_row($result)){ foreach ($rows as $row) { print $row->date; } } ?> The query didn't return anything. I'm guessing the -> (what's it called?) requests column name from the array/query stated?
  6. Ok, so I really have 2 questions and was wondering if anyone could shed some light one them. Firstly... I have table like this: |id|name|date|activtiy| |1|Jo Bloggs|1238411497|went to the Circus| |2|Fred Kent|1238411497|went to School| |3|Jane Bloggs|1238411596|went Sailing| |4|Mike Smith|1238411596|broke his leg| And I want to format my results like this: 1238411497 Jo Bloggs went to the Circus. Fred Kent went to School. 1238411596 Jane Bloggs went Sailing. Mike Smith broke his leg. I've looked into foreach loops and in all honesty, the confuse me a little and I wonder if they are event appropriate (I assumed by the name that they would be). What would be the best way to go about doing this? Second question would is; I have a table like this: |name|pie|cake|bread|eggs|butter|cheese|pancakes| |Jo Bloggs|0|1|0|0|0|1|0| |Mike Smith|1|1|1|1|0|1|0| And I'd like to create a list which echos the things a person likes... so: Jo Bloggs |cake(dropdown)| |eggs| Mike Smith |pie(dropdown)| |cake| |bread| |eggs| |cheese| Again, what would be the best way to do this? I don't really know where to start on thsi one. I know you can select column names, but how do you select column names based on their data being 1 or 0. Any help greatly appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.