Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Code into PHP Code (if)
Old 11-03-2010, 01:34 PM PHP Code into PHP Code (if)
emsanator's Avatar
Novice Talker

Posts: 7
Name: Emre
Trades: 0
Hi Guys!

i need help, how can i add php code into php code?


Add code:
PHP Code:
<?php echo session->userinfo['id'];?>  // This code: User's ID see
PHP Code:
<?php

if($session->userinfo['id']== ** HERE ADD **)
echo 
$notes
else
echo 
" - content message - ";

?>
Thanks!

Last edited by emsanator; 11-03-2010 at 01:40 PM..
emsanator is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-03-2010, 01:54 PM Re: PHP Code into PHP Code (if)
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I'm not sure what you're trying to do. 'How can I add php code into php code' doesn't say a whole lot. What is it you want to add to the section you marked 'HERE ADD'?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-03-2010, 05:16 PM Re: PHP Code into PHP Code (if)
emsanator's Avatar
Novice Talker

Posts: 7
Name: Emre
Trades: 0
Hi Matt thanks for the reply..

** Here Add ** =
PHP Code:
<?php echo session->userinfo['id'];?>
if($session->userinfo['id']== $session->userinfo['id']) Not working..

where something is wrong?
emsanator is offline
Reply With Quote
View Public Profile
 
Old 11-03-2010, 05:32 PM Re: PHP Code into PHP Code (if)
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
You're comparing something to itself. That condition will always evaluate to true. Can you explain more what you are attempting to do and what you mean by 'not working'.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-03-2010, 06:46 PM Re: PHP Code into PHP Code (if)
emsanator's Avatar
Novice Talker

Posts: 7
Name: Emre
Trades: 0
According to the number you want users to open the contents of the site ..
example,

User ID: 2 -> Site content: 2 number user's contents
User ID: 3 -> Site content: 3 number user's contents

User ID: 10 -> ID:2's user can not see the contents
emsanator is offline
Reply With Quote
View Public Profile
 
Old 11-03-2010, 07:01 PM Re: PHP Code into PHP Code (if)
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Something like this?:
PHP Code:
if($session->userinfo['id'] == 2)
{

}
elseif(
$session->userinfo['id'] == 3)
{

}
elseif(
$session->userinfo['id'] == 4)
{


or you could use a switch statement
PHP Code:
switch($session->userinfo['id'])
{
case 
2:
     
//do something here
break;
case 
3:
     
//do something here
break;

By the way, I'm still not sure what you are trying to do overall. How many users do you plan on doing this for? This solution won't scale well at all.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 11-03-2010 at 07:02 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-03-2010, 11:51 PM Re: PHP Code into PHP Code (if)
Average Talker

Posts: 22
Trades: 0
I am not sure you are asking the question that you really want to know the answer too. Cause if I do exactly what you are asking for "add php code into php code" then what you are saying is :
Code:
<?php
  echo "Hello" . <?php echo "Dude"; ?>;
?>
Which can't be done. Also what NullPointer says, if you compare anything to itself it will be true.
__________________
The Ultimate Wordpress Themes

Please login or register to view this content. Registration is FREE
swoopster is offline
Reply With Quote
View Public Profile Visit swoopster's homepage!
 
Old 11-04-2010, 03:04 AM Re: PHP Code into PHP Code (if)
emsanator's Avatar
Novice Talker

Posts: 7
Name: Emre
Trades: 0
PHP Pages: OK
DB Tablo:
OK
User Interface:
OKbut
user-specific show:
No

I want do to
:

emsanator is offline
Reply With Quote
View Public Profile
 
Old 11-06-2010, 07:04 PM Re: PHP Code into PHP Code (if)
Junior Talker

Posts: 4
Name: Tarquin
Trades: 0
So you want to pull information from a database based on the users ID? Like a personal notes section?

PHP Code:

<?
    $myid 
session->userinfo['id'];
    
$ObtainInfo mysql_query("SELECT * FROM `MyDB` WHERE `ID` = '".$myid."' LIMIT 1");
    
$Info mysql_fetch_array($ObtainInfo);

    echo 
$Info['note_content'];
?>
I'm not the most efficient coder in the world but I'm going to assume this is what you want to do.

Last edited by Tarquin; 11-06-2010 at 07:05 PM..
Tarquin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Code into PHP Code (if)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45146 seconds with 12 queries