Mysql_result() Function

I am unsure if I am storing the user’s selection correctly to reference the database.

//below code is in if(!isset) function

$result1=mysql_query(“Select Equip_Id FROM maint_equip Where Dept=$dept”);
mysql_close():

print"Chose the equipment to be viewed";
print"

select name=equip Style=font-size :16pt>";
print" OPTION value=’ '>";

while($line=mysql_fetch_array($result1))
{
foreach ($line as $value)
{ print"<OPTION value= $value“;
print”>$value";
}
} print"")

?

Click submit to post your entry:

<?php }else() //if(!isset) else section //connect and select database $result3=mysql_query("Select * FROM `maint_equip` Where `Equip_ID`=$equip"); $serial=mysql_result($result3, "0", "Serial_Number") //The first line above should select all data from the table based on the user's submission above. //The second line should take the data under the chart heading "Serial_Number" correct? Next I just display all the data in a table which I already have done. I am fairly new to php but I have picked it up quickly as I am very familar with other programming languages. I am just stuck with this issue, and any help would be apprciated.

$result1=mysql_query(“Select Equip_Id FROM maint_equip Where Dept=$dept”);
mysql_close():

print"Chose the equipment to be viewed";
print"

select name=equip Style=font-size :16pt>";
print" OPTION value=’ '>";

while($line=mysql_fetch_array($result1))
{
foreach ($line as $value)
{ print"<OPTION value= $value“;
print”>$value";
}
} print"")

?

I guess my main question is that does a the selection made by the user in this drop down menu become stored into the $value variable?

Do I have to refresh the page or something??

Plz help I really need to solve this, If I could figure this out It’d be a big break thru for what Im doing to finish it.

Syntax for mysql_result : string mysql_result ( resource $result , int $row [, mixed $field = 0 ] )

The sencond parameter in $serial=mysql_result($result3, “0”, “Serial_Number”)
should be of integer type. i.e 0 instead of “0”. :slight_smile:

http://php.net/manual/en/function.mysql-result.php

That makes sense, My original code is on a different computer so I’ll have to try it tommorrow.

Does it seem like I’m using the right variables to access the data? I was also thinking that the user’s selection wasn’t properly being stored into the $equip variable.

I was going to try:

print"

<select name=equip STYLE=font-size: =16pt>";
print""
print"$equip"
print"

Instead of:

print"

<select name=equip STYLE=font-size: =16pt>";
print"

Would that enter the selection into the equip variable.
I have it declared as $equip=$_POST[“equip”];

Thanks for your help!

Can u paste your entire code and then ask for what exactly you want? Because with this little snippets I’m not getting a clear picture.

My two drop down menus work ok, it’s just when I use the mysql_result() function the data I need from the database is not showing up

[php]

Equipment Database

<?php $dept=$_GET['var1']; $equip=$_POST['equip']; if(!isset($_POST['submit'])) { ?>

Choose a Business Unit:


<?php // ++++++++++++++LOAD DEPARTMENT DROPDOWN+++++++++ if($dept) { //Reload if a value for dept is not entered print "" ; print "$dept"; print ""; }else{ //Display forging and conventional option print"" ; print""; print"Conventional"; print"Forging"; print""; } //Connect and check database. $database="equipid"; mysql_connect("192.168.0.225"); mysql_select_db($database) or die( "Unable To Connect to SQL Database"); $result1=mysql_query("SELECT `Equip_ID` FROM `machine` WHERE `Department`='$dept'"); mysql_close(); print "

"; print "Choose the equipment to be viewed: "; print "

"; print ""; while ($line = mysql_fetch_array($result1)) { foreach ($line as $value) { print "$value"; } print ""; ?>




Click Submit to Post Your Entry:

<?php

//+++++++++++++Next Screen Showing Machine Information+++++++++++++++++++

}else{

$set=0;
$database=“equipid”;
mysql_connect(“192.168.0.225”);
mysql_select_db($database) or die( “Unable To Connect to SQL Database”);
$result2=mysql_query(“SELECT * FROM machine WHERE Equip_ID=’$equip’”);
$equipnum=mysql_result($result2,$set,“EquipFile #”);
$mfg=mysql_result($result2,$set,“Mfg”);
$mfgs=mysql_result($result2,$set,“Mfg Serial and/or Model #”);
mysql_close();

$output=mysql_fetch_array($result2);
echo $output;

?>

Equipment Number: <?php $equip ?>
Mfg Equip File # Mfg Serial # and/or Model#
<?php $mfg ?> <?php $equipnum ?> <?php $mfgs ?>



<TABLE>
<tr WIDTH="1000" align="center" valign="middle">
<td WIDTH="400"></td>
<td>
<?php } ?>

[/php]

VERY VERY STUPID MISTAKE…

I didn’t have the echo before the variables…

Sponsor our Newsletter | Privacy Policy | Terms of Service