Page 1 of 1

dont know if it works! help

Posted: Fri Nov 06, 2009 7:57 am
by Goofan
Hi i got a code that i dont know if its possible to work or not

i need to get a units from a specific row and a Buyfor at the same and so on but then i need to get same info but on a diffrent row...

my idé were this but it dont work as i want it to...

my first php script is for that i said...
my second php scripthing is to get a specifik row in a diffrent datatable in the database that i get to work

well im wondering if its possible to have 2 php scripts like this without them bothering each other and plz tell me if i got anything wrong in php script 1 as its a code i cant get to work

Code: Select all

 
<?php
include "../login/database.php";        //page to where the database setting is
$sql="SELECT * FROM units";     //selecting all from DB "Konto" where saved_id is the same as in the array $id
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tall. //hämtar all info från tabell
 
                 
while($row = mysql_fetch_array( $result )) //hämtar info från tabell.
{
    $Units1=$row['Units']"' WHERE saved=1"; // i got a row in my Tabledata called saved with the number 1 in.
    $AtkArm1=$row['AtkArm']"' WHERE saved=1";
    $Buyfor1=$row['Buyfor']"' WHERE saved=1";
    $Sellfor1=$row['Sellfor']"' WHERE saved=1";
    $Units2=$row['Units']"' WHERE saved=2";// i got a row in my Tabledata called saved with the number 2 in.
    $AtkArm2=$row['AtkArm']"' WHERE saved=2";
    $Buyfor2=$row['Buyfor']"' WHERE saved=2";
    $Sellfor2=$row['Sellfor']"' WHERE saved=2";
    $Units3=$row['Units']"' WHERE saved=3";// i got a row in my Tabledata called saved with the number 3 in.
    $AtkArm3=$row['AtkArm']"' WHERE saved=3";
    $Buyfor3=$row['Buyfor']"' WHERE saved=3";
    $Sellfor3=$row['Sellfor']"' WHERE saved=3";
}
exit;
?>
 
 
 
 
<?php
 
 
  $id =(isset($_GET['saved_id'])) ? (int)$_GET['saved_id'] : false;
    if($id !== false) {
    $sql="SELECT * FROM inventory WHERE saved_id=$id";      //selecting all from DB "Konto" where saved_id is the same as in the array $id
 } 
    else 
 {
    echo "NO saved_id!";
 }
     
 
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tall. //hämtar all info från tabell
 
                 
while($row = mysql_fetch_array( $result )) //hämtar info från tabell.
{
    $namn=$row['namn'];
}
?>
 
 


thanks for all the help




-Thomas

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 8:01 am
by Goofan
ohh and i get a parse error on line 9

Code: Select all

$Units1=$row['Units']"' WHERE saved=1";

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 8:06 am
by VladSun
String concatenation is done by using the "." operator:

Code: Select all

$s = $s1 .$s2." its a string";

.

Posted: Fri Nov 06, 2009 8:13 am
by Goofan
.

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 8:21 am
by VladSun
Fix all of the lines similar to this one:

Code: Select all

$Sellfor3=$row['Sellfor']"' WHERE saved=3";
like this:

Code: Select all

$Sellfor3=$row['Sellfor']."' WHERE saved=3";

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 8:43 am
by Goofan
now i got this instead of parsal error


here is the code of where im getting the info out to show:

Code: Select all

 
<tr>  
        <td>
        <font color="black"><b><?php echo $Units3; ?></b></font>
        </td>
        <td>
        <font color="black"><?php echo $AtkArm3; ?></font>
        </td>
        <td>
        <font color="black"><?php echo $Buyfor3; ?></font>
        </td>
        <td>
        <font color="black"><?php echo $Sellfor3; ?></font>
        </td>
 
 
 

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 8:51 am
by Goofan
and as it said pikeman... and such that. was from my first row in my DataTable. it is like it dont get the saved id... from the others....

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 12:02 pm
by Goofan
can someone type me a code that do what i need...? i need to have 2 dataTables and one of them is getting an $id and the other got one in the table allready

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 12:03 pm
by Goofan
and then in the tables i got 3 rows i need to get them out aswell as sen in the text above...

Re: dont know if it works! help

Posted: Fri Nov 06, 2009 3:10 pm
by RobertGonzalez
Locked for double posting.

Please direct all further questions/answers to this thread.