Jump to content

littlegeek

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    Lake Ariel Pennsylvania

littlegeek's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok so i recreated my query and i now have the following $trans = mysql_query("SELECT *, amount, 'C' as type, date FROM Credits WHERE account_number = '$accnt' UNION SELECT *, amount, 'D' as type, date FROM Debits WHERE account_number = '$accnt'"); // List trans while($rows = mysql_fetch_array($trans)) { //Define Vars $amount = $rows['C']; close?
  2. omg thnk you took a min or two to get the syntax right but i got it now i just have to figure if i can define which table to display from i.e. while($rows = mysql_fetch_array($trans)) { //Define Vars $amount = $rows['Credits.amount']; // From Credits table $amount2 = $rows['Debits.amount']; // From Debits table echo "<tr>"; echo "<td>RI $amount</td>"; echo "<td>RI $amount2</td>"; echo "</tr>"; } ^ this doesn't work as is thanks again for the union explanation
  3. so i have this query it works perfectly. in fact it works so good that it doubles everything!!!! if i have one debit transaction and one credit transaction in each separate table it will list it twice on the displayed page so I'll have the same two transactions listed 4 times i am stumped $trans = mysql_query("Select Credits.* , Debits.* FROM Credits, Debits WHERE Credits.account_number AND Debits.account_number = '$accnt' ORDER BY Credits.date AND Debits.date ASC") or die(mysql_error()); while($rows = mysql_fetch_array($trans)) { //Define Vars $amount = $rows['amount']; $date = $rows['date']; $time = $rows['time']; $ref = $rows['ref_number']; $amount2 = $rows['Debits.amount']; $date2 = $rows['Debits.date']; $time2 = $rows['Debits.time']; $ref2 = $rows['Debits.ref_number']; // Display Accounts echo "<tr>"; echo "<td><input name='transaction' type='radio' value='$ref_number'></input></td>"; echo "<td>$date</td>"; echo "<td>$time</td>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td> </td>"; echo "<td>RI $amount</td>"; echo "<td>RI $amount2</td>"; echo "<td> </td>"; echo "</tr>"; } any incite would be helpful thanks
  4. @Russellreal everything is correct i have triple checked and yet all i get is the int no color name i have no clue as to why but the int for the mfg is replaced with Pontiac or Volkswagen perplexing
  5. my brain is numb and i just got home from work everything is superb but the color and IDK why i keep looking over and over the query and it should work but i still get a i,1,2,3 etc... Why doesn't this work $mfg = mysql_query("SELECT a.*, b.shade, c.make FROM cars a JOIN color b ON b.id = a.color JOIN mfg c ON c.id = a.make WHERE a.make = a.make") or die(mysql_error()); echo "<body text='#FFFFFF'>"; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Name</th><th>VIN</th><th colspan='10'>Options</th></tr>"; while ($mic = mysql_fetch_assoc($mfg)) { $name = $mic['nick']; $vin = $mic['vin']; $make = $mic['make']; $model = $mic['model']; $year = $mic['year']; $color = $mic['color']; $plate = $mic['plate']; $purchdate = $mic['puchdate']; $purchprice = $mic['puchprice']; echo "<tr>"; echo "<td>"; echo "<a href='car.php'>$name</a>"; echo "</td>"; echo "<td>"; echo $vin; echo "</td>"; echo "<td>"; echo $make; echo "</td>"; echo "<td>"; echo $model; echo "</td>"; echo "<td>"; echo $year; echo "</td>"; echo "<td>"; echo $color; echo "</td>"; echo "<td>"; echo $plate; echo "</td>"; echo "<td>"; echo $purchdate; echo "</td>"; echo "<td>"; echo "$",$purchprice; echo "</td>"; echo "<td>"; echo "<a href='parts.php'>Parts</a>"; echo "</td>"; echo "<td>"; echo "<a href='list.php'>Maintenance</a>"; echo "</td>"; echo "<td>"; echo "<a href='notes.php'>Notes</a>"; echo "</td></tr>"; } echo "</table>";
  6. WORKS GREAT for mfg in table if there is a static variable i.e 1 so i tried this while($det = mysql_fetch_assoc($cool)) { $makeset = $det['make']; $i = $makeset; } $mfg = mysql_query("SELECT a.*, b.shade, c.make FROM cars a JOIN color b ON (b.id = a.color) JOIN mfg c ON c.id = a.make WHERE a.make = $i") or die(mysql_error()); didn't work but was worth a try. then i tried this function makeset() {while($det = mysql_fetch_assoc($cool)) { $makeset1 = $det['make']; $i = $makeset; } } $cool = mysql_query("Select * FROM cars Where id > 0"); $mfg = mysql_query("SELECT a.*, b.shade, c.make FROM cars a JOIN color b ON (b.id = a.color) JOIN mfg c ON c.id = a.make WHERE a.make = makeset()") or die(mysql_error()); resulted in telling me this contradictory error => FUNCTION vehicel.makeset does not exist!!! i am so thankful for you help this is really exciting for me to see this work correctly PS the only thing that doesn't work is the color haven worked on that part yet but I'm sure its similar to mfg code so no biggie so you have it here is full code that !!works!! <?php include 'dbc.php'; page_protect(); ?> <?php $cool = mysql_query("Select * FROM cars Where id > 0"); $mfg = mysql_query("SELECT a.*, b.shade, c.make FROM cars a JOIN color b ON (b.id = a.color) JOIN mfg c ON c.id = a.make WHERE a.make = '1'") or die(mysql_error()); //text='#FFFFFF'> echo "<body "; echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Name</th><th>VIN</th><th colspan='10'>Options</th></tr>"; while ($mic = mysql_fetch_assoc($cool)) {while($mic2 = mysql_fetch_assoc($mfg)) { $name = $mic['nick']; $vin = $mic['vin']; $make = $mic2['make']; $model = $mic['model']; $year = $mic['year']; $color = $mic2['color']; $plate = $mic['plate']; $purchdate = $mic['puchdate']; $purchprice = $mic['puchprice']; echo "<tr>"; echo "<td>"; echo "<a href='car.php'>$name</a>"; echo "</td>"; echo "<td>"; echo $vin; echo "</td>"; echo "<td>"; echo $make; echo "</td>"; echo "<td>"; echo $model; echo "</td>"; echo "<td>"; echo $year; echo "</td>"; echo "<td>"; echo $color; echo "</td>"; echo "<td>"; echo $plate; echo "</td>"; echo "<td>"; echo $purchdate; echo "</td>"; echo "<td>"; echo $purchprice; echo "</td>"; echo "<td>"; echo "<a href='parts.php'>Parts</a>"; echo "</td>"; echo "<td>"; echo "<a href='list.php'>Maintenance</a>"; echo "</td>"; echo "<td>"; echo "<a href='notes.php'>Notes</a>"; echo "</td></tr>"; } } echo "</table>"; ?>
  7. hello again i have reinserted what you have given me @RussellReal and i now have an error that i don't understand because i think everything is correct. <?php //get data $mfg = mysql_query("SELECT id, shade As (SELECT shade FROM color WHERE color.id = cars.color), carMake As (SELECT make FROM mfg WHERE make.id = cars.make) FROM cars WHERE make = '1'"); echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Name</th><th>MFG</th><th>Model</th><th>Year</th></tr>"; //line 10 =>while ($mic = mysql_fetch_assoc($mfg)) { $name = $mic['nick']; $make = $mic['make']; $model = $mic['model']; $year =$mic['year']; echo "<tr>"; echo "<td>"; echo $name; echo "</td>"; echo "<td>"; echo $make; echo "</td>"; echo "<td>"; echo $model; echo "</td>"; echo "<td>"; echo $year; echo "</td></tr>"; } echo "</table>"; ?> the error i get is Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/tjc/list.php on line 10 p.s. srry for the long silence i had to go to work( stupid job lol) p.p.s thanks for all the help i really cant thank you enough
  8. <?php //get data $mfg = mysql_query("SELECT id, color As (SELECT shade FROM color WHERE color.id = colorId), make As (SELECT make FROM make WHERE make.id = makeId) FROM cars WHERE make = '1'"); echo "<table border=\"1\" align=\"center\">"; echo "<tr><th>Name</th><th>MFG</th><th>Model</th><th>Year</th></tr>"; while ($mic = mysql_fetch_assoc($mfg)) { $name = $mic['nick']; $make = $mic['make']; $model = $mic['model']; $year =$mic['year']; echo "<tr>"; echo "<td>"; echo $name; echo "</td>"; echo "<td>"; echo $make; echo "</td>"; echo "<td>"; echo $model; echo "</td>"; echo "<td>"; echo $year; echo "</td></tr>"; } echo "</table>"; ?> given output on execution => <table border="1" align="center"><tr><th>Name</th><th>MFG</th><th>Model</th><th>Year</th></tr><br /> <b>Warning</b>: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in <b>/var/www/tjc/list.php</b> on line <b>10</b><br /> </table>
  9. As for table structure i have the folloing tables: cars => id nick make model year vin color plate purchdate purchprice pic color => id shade maintenance=> id description sdate mileage cost shop invoice make => id mfg note => id cid note part => id part type service service => id type shop => id name so if i have a echoed table and i want to list all the cars from table cars i would like a result of: Jenna Jetta | Volkswagen | Jetta GL | 1996 | blah blah | black | blah | xx/xx/xxxx | $2000.00 | pic but the table cars has data: Jenna Jetta | 1 | 1996 | blah blah | 1 | blah | xx/xx/xxxx | 2000.00 | directory so i ask about how to if the "1's" //if (cars.color==color.id) //{echo 'color.shade'; //else //echo 'cars.color'; //} same sort of thing is needed for mfg table for make in cars table. srry i didnt include this earlier. hope this helps you help me thanks for the quick responses and i hope that i am not misunderstanding what was already posted in response. thanks again littlegeek
  10. hello all, i have been sitting here googleing and googling but i can't seem to find what im looking for. i am tring to create a personal site that lets me note services i do for my cars. I have multiple tables (cars, color, mfg, ...) in the main table cars i insted of putting the color black i put and int(11) of 1 which is suppose to "if statement" to the table colors and produce the correct color. same for mfg. although nothing i have tried has helped i always just have the else of the if echoed out. i have heard of union and join left right i am so unsure of what is need any insite would be useful. thanks in advance.
  11. Well A+ great thank you for that I have errors now! I'll have to look in to what I did wrong. I’m sure I’ll be writing again but I will research well before hand. Thanks again Please have a look if you wish. I always like a little constructive criticism.
  12. At the fear of bothering all you, I will post here hoping that I am in the write section. I am new to php and mysql. I am using such to develope a webpage for my new business. I do believe that my php scripting is turned on because I have one script that "works". However when I take the wheel and write a script of my own and try to view it all I get is a blank white page and no errors nor anything that I wanted to display. I have tried numerous attempts at tiring to get anything to show up all I can ever seem to do is "echo" something anything else is null in displaying. Please feel free to take a look. http://72.28.26.162/rc/ phpinfo.php is accessible if you insert it after the last / (http://72.28.26.162/rc/phpinfo.php) I am at a loss. I have spent hours looking for something I miss during set up or with my procedure. I thank whomever my help me in advance. I am running ubuntu server 10 Apache/2.2.16 port 80 (Please advise if you need anything else) thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.