Mobile Devices: Lite Theme Citroën: Citroën Trader | Saxo Trader | C2 Trader Peugeot: Peugeot Trader | 106 Trader Enthusiast: Saxperience


Go Back   Saxperience - Citroen Saxo Forum > Other... > Gaming, IT, Multimedia & Music

Gaming, IT, Multimedia & Music Please use this forum to discuss Gaming, IT, Multimedia & Music.

Reply
 
Thread Tools Display Modes
Old 8th October 2013, 09:54   #1
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default PHP Help

Anyone on here proficient in PHP that could lend a hand?

Quote:
<?php
$conn = odbc_connect('CS_CRM','','');
$sql = "SELECT Person_no, firstname + ' ' + Surname AS AdvisorName FROM People where organisation_no is not null and active = 'Y' ORDER BY Firstname ASC";
$result = odbc_exec($conn, $sql) or die("SELECT Error: ".mysql_error());;


$id=$row["Person_no"];
$thing=$row["AdvisorName"];


echo "<table>";
echo "<form method=\"POST\" action=\"LTResult.php\">";
echo "<tr><th>Advisor Name</th></tr>";
echo "<tr><td><select name = \"AdvisorName\">";
$options.="<OPTION VALUE=\"$id\">".$thing."</option>";

while ($row=odbc_fetch_row($result))

{
echo "<option value=\".&options.\"</option>";
}
echo "</select>";
echo "<td><input type = \"submit\" value = \"Search\"></td></tr>";
echo "</form>";
echo "</table>";
?>
Why am I not getting results in my dropdown box?

I am getting a list of blank records yet the query works fine as I have run it in query analyzer.
__________________
Quote:
Originally Posted by Giraffe View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 8th October 2013, 12:11   #2
Scottp
Administrator
Content ContributorScotland Region Member
 
Scott's Avatar
 
Join Date: Dec 2002
Location: Glasgow United Kingdom (Scotland)
Posts: 26,097
Car(s): Chelski Traktor
Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!
Default

I know nowt about PHP so i was only glancing to see if i could spot any irregular namings etc.. so i have no idea if the two i have highlighted below are relevant or not. Maybe i should stay out of this

Quote:
echo "<table>";
echo "<form method=\"POST\" action=\"LTResult.php\">";
echo "<tr><th>Advisor Name</th></tr>";
echo "<tr><td><select name = \"AdvisorName\">";
$options.="<OPTION VALUE=\"$id\">".$thing."</option>";

while ($row=odbc_fetch_row($result))

{
echo "<option value=\".&options.\"</option>";
__________________
Saxperience Blogs|iTrader Explained |Newbies Information|Articles|FAQ's

If you feel something untoward is being posted hit the button at the side of the post.
Scott is offline   Reply With Quote
Old 8th October 2013, 13:30   #3
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

Quote:
Originally Posted by Scott View Post
I know nowt about PHP so i was only glancing to see if i could spot any irregular namings etc.. so i have no idea if the two i have highlighted below are relevant or not. Maybe i should stay out of this
LOL the parts you highlighted are the hmtl elements and are irrelevant to the php code really

Sorted it with this in the end:

Quote:
<?php
$conn = odbc_connect('CS_CRM','','');
$sql = "SELECT Person_no, firstname + ' ' + Surname AS AdvisorName FROM People where organisation_no is not null and active = 'Y' ORDER BY Firstname ASC";
$result = odbc_exec($conn, $sql) or die("SELECT Error: ".mysql_error());;

echo "<table>";
echo "<form method=\"POST\" action=\"LTResult.php\">";
echo "<tr><th>Advisor Name</th></tr>";
echo "<tr><td><select name = \"Advisors\">";

while ($row=odbc_fetch_row($result))
{
$id = odbc_result($result,1);
$thing = odbc_result($result,2);

echo "<OPTION VALUE =\"$id\"]\>".$thing."</OPTION>";
}
echo "</select>";
echo "<td><input type = \"submit\" value = \"Search\"></td></tr>";
echo "</form>";
echo "</table>";
?>
__________________
Quote:
Originally Posted by Giraffe View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 8th October 2013, 13:53   #4
Scottp
Administrator
Content ContributorScotland Region Member
 
Scott's Avatar
 
Join Date: Dec 2002
Location: Glasgow United Kingdom (Scotland)
Posts: 26,097
Car(s): Chelski Traktor
Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!Scott is absolutely fabulous!
Default

bah here was me hoping the obvious may have been overlooked. Ill go back to spreadsheets
__________________
Saxperience Blogs|iTrader Explained |Newbies Information|Articles|FAQ's

If you feel something untoward is being posted hit the button at the side of the post.
Scott is offline   Reply With Quote
Old 8th October 2013, 13:57   #5
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

Quote:
Originally Posted by Scott View Post
bah here was me hoping the obvious may have been overlooked. Ill go back to spreadsheets
Cheers for the effort though.
__________________
Quote:
Originally Posted by Giraffe View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 8th October 2013, 14:11   #6
Alexp
Central South
Track / Motorsport Prep

Central South Region MemberSouth East Region Member
 
Alex's Avatar
 
Join Date: Jun 2006
Location: East Sussex
Posts: 3,105
Blog Entries: 9
Car(s): VTS :)
iTrader Score: 17 (100%)
Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!
Default

If you can use odbc_fetch_object it will save a couple lines
Quote:
<?php
$conn = odbc_connect('CS_CRM','','');
$sql = "SELECT Person_no, firstname + ' ' + Surname AS AdvisorName FROM People where organisation_no is not null and active = 'Y' ORDER BY Firstname ASC";
$result = odbc_exec($conn, $sql) or die("SELECT Error: ".mysql_error());;

echo "<table>";
echo "<form method=\"POST\" action=\"LTResult.php\">";
echo "<tr><th>Advisor Name</th></tr>";
echo "<tr><td><select name = \"Advisors\">";

while ($row=odbc_fetch_object($result))
{
echo '<OPTION VALUE="', $row->Person_no, '">', $row->AdvisorName, '</OPTION>';
}
echo "</select>";
echo "<td><input type = \"submit\" value = \"Search\"></td></tr>";
echo "</form>";
echo "</table>";
?>
__________________
Can I be your car fwrend??
Alex is offline   Reply With Quote
Old 8th October 2013, 15:13   #7
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

Quote:
Originally Posted by Alex View Post
If you can use odbc_fetch_object it will save a couple lines
I can't for some reason. Probably because I am interfacing PHP with SQL as opposed to MYSQL.
__________________
Quote:
Originally Posted by Giraffe View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Old 8th October 2013, 16:02   #8
Alexp
Central South
Track / Motorsport Prep

Central South Region MemberSouth East Region Member
 
Alex's Avatar
 
Join Date: Jun 2006
Location: East Sussex
Posts: 3,105
Blog Entries: 9
Car(s): VTS :)
iTrader Score: 17 (100%)
Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!Alex is absolutely fabulous!
Default

Quote:
Originally Posted by Brettles1986 View Post
I can't for some reason. Probably because I am interfacing PHP with SQL as opposed to MYSQL.
You using a local Access database?
__________________
Can I be your car fwrend??
Alex is offline   Reply With Quote
Old 8th October 2013, 16:16   #9
Brettles1986
Saxperience Post Whore
South Wales Region Member
 
Brettles1986's Avatar
 
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI Saxo VTS
Brettles1986 is on a distinguished road
Default

Quote:
Originally Posted by Alex View Post
You using a local Access database?
Nope, access is not involved at all. Database is MS SQL.
__________________
Quote:
Originally Posted by Giraffe View Post
I'm happy being a north easternly smoggie bender.
Brettles1986 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 13:39.