PHP programmer needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

PHP programmer needed

Post by utahfriend »

I need someone who is willing to do some trouble shooting of php programs that was written by a local IT guy and then he left me hanging with some of the things not working. I am willing to pay cash for the help!
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Whaddya need?
utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

Post by utahfriend »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


One problem I am having is that when I do a SELECT with MYsql, it doesn't work if I use the WHERE clause, as below:

Code: Select all

function dd_template($template_id=0)
     {
 
       $text = "<option value='Select' selected='selected'>Select</option>";
       //$sql = "SELECT * FROM members_cat order by cat_name"; 
 
       $sql = "SELECT cat_id,cat_name FROM members_cat where user_id=$user_id order by cat_name";
       $result = mysql_query($sql);
       while($row = mysql_fetch_array($result))
        {
         $text .= "<option value='$row[cat_name]'";
         if ($row["cat_id"] == $cat_id)
          {
           $text .= " Selected";
          }
         $text .= "> $row[cat_name]</option>\n";
   }
  $text .= "</select>";
       return $text;
}

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

function dd_template($template_id=0)
{

$text = "<option value='Select' selected='selected'>Select</option>";
//$sql = "SELECT * FROM members_cat order by cat_name";

$sql = "SELECT cat_id, cat_name FROM members_cat where `user_id` = '".$user_id."' order by cat_name";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$text .= "<option value='$row[cat_name]'";
if ($row["cat_id"] == $cat_id)
{
$text .= " Selected";
}
$text .= "> $row[cat_name]</option>\n";
}
$text .= "</select>";
return $text;
}
If you're willing to pay for that send paypal to luke.visinoni@gmail.com lol
utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

Post by utahfriend »

That still does not find any items in the MySql table. There are 46 items in the database that should show. Why is it not finding the items?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

print out your SQL query to make sure your variables are set.

Code: Select all

echo $yoursqlquery;
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

Post by utahfriend »

I found the problem thanks to you! I have lots more, my I email you or would you rather do it here?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

post it here... it's what we do :D
utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

Post by utahfriend »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


The same code that we just fixed pulls categories from a database and allows a user to change the category assigned to a client.  When he opens the page to edit the client, the drop down menu shows "select"  If the user makes a change somewhere else on the form and leaves this unchanged, when saved it makes the category change to "Select".  How can I make the drop down menu show in the window what is currently saved so that when it is resaved, it does not change the category unless the user makes the change in the drop down menu?

You can see what I am talking about by going to http://store.globalmarketingplus.com/Us ... rlist.html and then click on the word edit on any line and looking at the two dropdown menus I have there.

This is the code we are working on:

Code: Select all

function dd_template($template_id=0) 
{ 

$text = "<option value='Select' selected='selected'>Select</option>"; 
//$sql = "SELECT * FROM members_cat order by cat_name"; 

$sql = "SELECT cat_id, cat_name FROM members_cat where `user_id` = '".$user_id."' order by cat_name"; 
$result = mysql_query($sql); 
while($row = mysql_fetch_array($result)) 
{ 
$text .= "<option value='$row[cat_name]'"; 
if ($row["cat_id"] == $cat_id) 
{ 
$text .= " Selected"; 
} 
$text .= "> $row[cat_name]</option>\n"; 
} 
$text .= "</select>"; 
return $text; 
}  


Thank you

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Start using tags! :evil:
utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

Post by utahfriend »

Thank you for letting me know. I will do that from now on!
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

Code: Select all

function dd_template($template_id=0) 
{ 

$text = "<option value='Select'>Select</option>"; 
//$sql = "SELECT * FROM members_cat order by cat_name"; 

$sql = "SELECT cat_id, cat_name FROM members_cat where `user_id` = '".$user_id."' order by cat_name"; 
$result = mysql_query($sql); 
while($row = mysql_fetch_array($result)) 
{ 
$text .= "<option value='$row[cat_name]'"; 
if ($row["cat_id"] == $cat_id) 
{ 
$text .= " Selected"; 
} 
$text .= "> $row[cat_name]</option>\n"; 
} 
$text .= "</select>"; 
return $text; 
}
that should do the trick but i don't see where $cat_id is coming from, or $user_id. if this worked
shiznatix@wesmokerocks.com :wink:
utahfriend
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 12:25 pm
Location: Bountiful, Utah

Post by utahfriend »

$cat_id is part of the database and $user_id is a session variable.

I copied and pasted the code you sent in your last post, but it is still not highlighting the previous saved field, it shows "Selected" which will change the field to "Selected" if saved. You can see what it is doing at http://store.globalmarketingplus.com/Us ... tailsId=12

Thanks
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

HAHA wesmokerocks.com hahahaha
sheila
Forum Commoner
Posts: 98
Joined: Mon Sep 05, 2005 9:52 pm
Location: Texas

Post by sheila »

utahfriend wrote:$cat_id is part of the database and $user_id is a session variable.
No, $row['cat_id'] comes from the database. Where does $cat_id come from? Is it defined in the main part of the script? Also $template_id is never used. Maybe that should be $cat_id?

Code: Select all

function dd_template($cat_id=0)
Just guessing here.
Post Reply