$query = $this->EE->db->query(“SELECT field_id_1 FROM exp_channel_data”);
if ($query->num_rows() > 0) { foreach($query->result_array() as $row) { echo $row[‘field_id_1’].” \n”; } }
I am trying to get the value from “Field_ID_1” for the particular entry that is being viewed. However, the above code returns all the values in the table/all entries, not just the value for that specific entry.
Perhaps I am going about this in the wrong way? Basically, I need to use a php script to accomplish what I want, but I don’t know what variable to use in SELECT/FROM/WHERE that will give me the information related to that specific page. (Yes, I am using this code on the actual entry url page and not on the general ‘index’ page.)
Help!
Thanks in advance!
Ok, I’ve tried doing a simple query just to get the entry_id number of that particular entry page, and can’t even get that.
I’ve used GET, and REQUEST… I just get an ‘undefined variable’ error message.
How can I get the entry_id number using a query in a php script outside of the EE {variables}? Because the ee query function does not allow me to update, insert, or delete I have to do this in a php script… (No, SafeCracker will not help me, I’ve already looked at that option).
I simply need to do a php script and be able to return the entry_id…
I’ve tried:
<?php echo $_GET [“entry_id”]; ?> <?php echo $_REQUEST [“entry_id”]; ?>
Both return an error message. I’ve tried using “$entry_id” as well.
Why won’t this work?
pulls out hair
Any help would be appreciated.
Maybe I’m missing something obvious but can’t you just use your select query, and add a WHERE statement - such as WHERE entry_id == {segment_3} (may need quotes), and set the php parsing stage accordingly?
It’d help to know what you’re trying to accomplish, since everything you’ve mentioned could be done easily with a standard exp:channel:entries tag?
Hi there @nnete,
Is this related to your other thread here?
I’m going to migrate this thread over into Development and Programming so the discussion can continue.
Feel free to start a new thread if you need further assistance.
Cheers,
@nnette,
You can use ExpressionEngine tags in PHP in your templates, but there are some rules at play. Have a look at this resource by Low. It details the ExpressionEngine parsing order fairly well.
Cheers!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.