dont know if it works! help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

dont know if it works! help

Post 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
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: dont know if it works! help

Post by Goofan »

ohh and i get a parse error on line 9

Code: Select all

$Units1=$row['Units']"' WHERE saved=1";
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: dont know if it works! help

Post by VladSun »

String concatenation is done by using the "." operator:

Code: Select all

$s = $s1 .$s2." its a string";
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

.

Post by Goofan »

.
Last edited by Goofan on Fri Nov 06, 2009 12:32 pm, edited 1 time in total.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: dont know if it works! help

Post 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";
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: dont know if it works! help

Post 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>
 
 
 
Attachments
this is what i get instead of the parsal error
this is what i get instead of the parsal error
failed.jpg (35 KiB) Viewed 476 times
Last edited by Goofan on Fri Nov 06, 2009 9:43 am, edited 1 time in total.
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: dont know if it works! help

Post 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....
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: dont know if it works! help

Post 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
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: dont know if it works! help

Post by Goofan »

and then in the tables i got 3 rows i need to get them out aswell as sen in the text above...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: dont know if it works! help

Post by RobertGonzalez »

Locked for double posting.

Please direct all further questions/answers to this thread.
Locked