Gaming, IT, Multimedia & Music Please use this forum to discuss Gaming, IT, Multimedia & Music. |
|
8th October 2013, 09:54
|
#1
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
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
I'm happy being a north easternly smoggie bender.
|
|
|
|
8th October 2013, 12:11
|
#2
|
Administrator
Join Date: Dec 2002
Location: Glasgow United Kingdom (Scotland)
Posts: 26,097
Car(s): Chelski Traktor
|
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>";
|
|
|
|
8th October 2013, 13:30
|
#3
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Quote:
Originally Posted by Scott
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
I'm happy being a north easternly smoggie bender.
|
|
|
|
8th October 2013, 13:53
|
#4
|
Administrator
Join Date: Dec 2002
Location: Glasgow United Kingdom (Scotland)
Posts: 26,097
Car(s): Chelski Traktor
|
bah here was me hoping the obvious may have been overlooked. Ill go back to spreadsheets
|
|
|
8th October 2013, 13:57
|
#5
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Quote:
Originally Posted by Scott
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
I'm happy being a north easternly smoggie bender.
|
|
|
|
8th October 2013, 14:11
|
#6
|
Central South
Join Date: Jun 2006
Location: East Sussex
Posts: 3,105
Car(s): VTS :)
|
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??
|
|
|
8th October 2013, 15:13
|
#7
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Quote:
Originally Posted by Alex
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
I'm happy being a north easternly smoggie bender.
|
|
|
|
8th October 2013, 16:02
|
#8
|
Central South
Join Date: Jun 2006
Location: East Sussex
Posts: 3,105
Car(s): VTS :)
|
Quote:
Originally Posted by Brettles1986
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??
|
|
|
8th October 2013, 16:16
|
#9
|
Saxperience Post Whore
Join Date: Aug 2010
Location: Little Mill, South Wales
Posts: 7,547
Car(s): Mondeo ST TDCI
Saxo VTS
|
Quote:
Originally Posted by Alex
You using a local Access database?
|
Nope, access is not involved at all. Database is MS SQL.
__________________
Quote:
Originally Posted by Giraffe
I'm happy being a north easternly smoggie bender.
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 07:21.
|