Page 1 of 2
PHP programmer needed
Posted: Thu Nov 10, 2005 12:29 pm
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!
Posted: Thu Nov 10, 2005 1:08 pm
by Luke
Whaddya need?
Posted: Thu Nov 10, 2005 2:13 pm
by utahfriend
feyd | Please use 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
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Thu Nov 10, 2005 2:26 pm
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
Posted: Thu Nov 10, 2005 3:04 pm
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?
Posted: Thu Nov 10, 2005 3:14 pm
by s.dot
print out your SQL query to make sure your variables are set.
Posted: Thu Nov 10, 2005 3:33 pm
by utahfriend
I found the problem thanks to you! I have lots more, my I email you or would you rather do it here?
Posted: Thu Nov 10, 2005 3:40 pm
by Luke
post it here... it's what we do

Posted: Thu Nov 10, 2005 3:48 pm
by utahfriend
Jcart | Please use 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
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Posted: Thu Nov 10, 2005 6:13 pm
by John Cartwright
Start using
tags!

Posted: Fri Nov 11, 2005 11:03 am
by utahfriend
Thank you for letting me know. I will do that from now on!
Posted: Fri Nov 11, 2005 11:49 am
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 
Posted: Fri Nov 11, 2005 12:05 pm
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
Posted: Fri Nov 11, 2005 12:19 pm
by Luke
HAHA wesmokerocks.com hahahaha
Posted: Fri Nov 11, 2005 12:23 pm
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?
Just guessing here.