Jump to content

villain222

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by villain222

  1. ok, well i gave up on the hell of dealing with nested if elses and while statements and went back to learn how to join 3 tables and that made things alot easier. sort of solved. by re engineering.
  2. Thanks ignace. That worked fine. mine might have worked, but as i was putting yours to test i realized why the one page i was using wasn't finding the variables. either way, it works now. Thanks again.
  3. villain222

    3 ways

    can someone, somewhere tell me what's wrong with this query? "SELECT items.*, image.imageid, image.imagename, tickets.item, tickets.paypal, tickets.amount FROM (items LEFT JOIN image ON items.imageid = image.imageid) LEFT JOIN tickets ON tickets.item = items.id WHERE items.id = $ticketItem" double checked all table labels, is the order wrong here? can I use the specific rows or do i need to use the generic (*) for all on all 3 tables?
  4. ifnull?? thats a new one. where about does it go? I'll check it out on php.net, but if you can give me and example that would be great. Thanks.
  5. Ok here's my problem, I have a second query happening inside another While loop and I want it to grab info for the corresponding entry. I can get it to work fine if there is and entry available. So what do i do when the matching entry is not available. I don't care that value is missing. That's expected. What I'm looking for is how handle the lack of the entry to specify the variables I want. $final = mysql_query("SELECT tickets.item, tickets.amount, tickets.paypal FROM tickets WHERE tickets.item = $id"); //SECOND QUERY ON INCLUDE FILE while ($row2=mysql_fetch_array($final)) { //IF $id VALUE IS NOT MATCHED I WANT $amount AND $paypalID TO = 0 $amount = $row2['amount']; $paypalID = $row2['paypal'];} if ($amount>0 && $paypalID>0){ echo $amount; $over= '<font size=4 color="red"><br>sold!</font>'; echo $over; $stop= "86";} elseif ($hrdif>$hours) { $payprice=$row['loprice']; echo $payprice; $over= '<font size=4 color="red"><br>sale over</font>'; echo $over; $stop= "86"; //$userCut=$payprice*0.98; -also on paypalIPN.php. HERE FOR TESTING. //echo $userCut; } else { //echo "current price: "; $payprice=round($row['price']-$hourly*$hrdif, 2); echo $payprice; $over= ""; $stop= "0"; }
  6. It worked using the example that Sasa provided. Thanks. you're in the comments of the code, bro.
  7. I removed the do while within the top while loop. The end result was the same. I think sasa's post is leading in the right direction from my brief look at it. I just have to get my results to post in each table cell. I'm going to try working on it now and see if we can get this solved.
  8. Sasa, thank you. I think i can work with that.
  9. well thanks for the Non-help in the "php coding HELP" forum. Its a sample of what I'm doing. I refine a lot later when i get the result i want, but anyway its reporting an error that it is expecting while. This is a bit of code I snatched else where and I've been trying to get the result I want. I removed the do-while Shizz. still the same as before. p.s. that accent was weak, it should have been done like this: LUkey har, yer code ain't even all Dat, mayn. u gon an' dun a wile lup an' inside Dat biznOtch U go all crazy an' add a du-wile?? WTF? Dat ain't even rite. Pull Dat du-wile outa there, cuz Dat b janky (really? Janky?).
  10. Ok, homies, can somebody bail me out. I can't come up with an answer. I have some stuff i want to query from a db and display in a table that is 4 to 5 columns wide and however many rows tall. I can get the results, but i can't get them to individually go each cell. I get a result and it repeats 5 times and then creates the new row and repeats the same thing. I want each box of the table to show a different result based on date. Here's the code i got. <? $sessionid = $_SESSION['userid']; $join = "SELECT items.*, image.* FROM items, image WHERE items.imageid = image.imageid AND items.userid = $sessionid ORDER BY dateposted DESC"; //----------- function maketable($join){ //count number of columns $columns = '5'; //echo $columns; //run the query $PicSQL = mysql_query($join) or die(mysql_error()) ; $itemnum = mysql_num_rows($PicSQL); while ($row=mysql_fetch_array($PicSQL)){ //echo $itemnum; if($itemnum > 0){ do{ echo "<tr>" ; for($x = 0; $x < $columns; $x++){ echo "<td>" .$row['name']. "</td>" ; } echo "</tr>" ; } while ($row=mysql_fetch_array($PicSQL)); } } } //-------------- echo "<center><table border=1>"; echo "<strong>"; maketable($join); echo "</tr></table><br>" ?>
  11. I'm having some trouble working on a site that i started a few years ago. I'm basically relearning how it was working, or not working. I've been able to figure out most, but I've come across something that I'm not finding online. What is the purpose of this $i here? $catSQL = "SELECT * from category"; $stSQL = mysql_query($catSQL) or die ("<br><font color='red'><b>There was a problem!</b></font><br><br>" . mysql_error()); while ($i < mysql_num_rows($stSQL)) { $catname=mysql_result($stSQL,$i,"name"); $catid=mysql_result($stSQL,$i,"id"); $categoryDropdown .= "<option value=".$catid.">".$catname."</option>"; ++$i; }
  12. I'm trying to make a script to check a files date time and if its under so many seconds long the page will refresh. here is what I've got. I've been testing the output of the date() functions but when i do the math all i get is a 0. where did i go wrong? is it just i can't do math with dates? Thanks in advanced. <html><head> <meta http-Equiv="Cache-Control" Content="no-cache"> <meta http-Equiv="Pragma" Content="no-cache"> <meta http-Equiv="Expires" Content="0"> <? $proFile = "profilePics/profile.jpg"; //if ( date ("m d Y H:i:s.") - date ("m d Y H:i:s.", filemtime($proFile)) <= 00 00 0000 00:00:04 ){ //this is where the magic should happen. //echo "<meta http-equiv="refresh" content='4'>"; } ?> </head> <? echo date ("m d Y H:i:s."); echo "<br>"; echo date ("m d Y H:i:s.", filemtime($proFile)); echo "<br>"; echo date ("m d Y H:i:s.") - date ("m d Y H:i:s.", filemtime($proFile)); //only outputs 0 ?>
  13. kenrbnsn your solution worked after I figured out why the form wasn't submitting. Thanks, I'll have to do some dissecting on your code to figure out what is happening exactly. We can put this one to bed.
  14. my first part: $status = "selfstatus.txt";//status file $fs = fopen($status, 'r'); $statusData = fread($fs, 1000); fclose($fs); $text = $_POST['edit'];//updated status post if ($text == NULL) { die(); } else { $text2 = $_POST['edit']; $fp = fopen ($status, "w"); fwrite ($fp, $text2); fclose ($fp); } My form area: /div><p><a href="#">STATUSESES!</a><br> <iframe src ="editstatus.php" width="450" height="100%" frameborder=0 scrolling=auto></iframe><!--status update frame --> <font size=1><div id="statusedit"><b>edit </b></div> <form id="statuseditbox" action="<?php echo $PHP_SELF; ?>" method="post"><!--status update form --> <div> <input type="text" name="edit" /> <input type="submit" value="update" /> </div> </form></font> </p> here is the edit status iframe source: <? //this pulls the status information from the file listed below $status = "selfstatus.txt"; $fs = fopen($status, 'r'); $statusData = fread($fs, 1000); fclose($fs); echo "<i> <font size=2>"; echo $statusData; //instantly reposts file contents. ?> whatcha talkin bout, Willis? does that help. it works while im on the page but then it rewrites when its opened for the first time i know i have a redundant file read,but im not calling the first
  15. here is an error from firefox when I hit submit: Firefox doesn't know how to open this address, because the protocol (notice) isn't associated with any program. the info is being posted to a page in an iframe. is that the problem?
  16. Ok its not that serious, but i'm losing sleep regardless. I have a situation of a page that loads a file with my current status on it. Problem is that when I first load it, the post data hasn't been created yet and that empty data is being written to the status file that my page loads the current status from. Otherwise its pretty slick and immediately posts. here's the code I've tried to use to fix the problem. $status = "selfstatus.txt";//status file $fs = fopen($status, 'r'); //this is how my page reads the current status file contents $statusData = fread($fs, 1000); fclose($fs); $text = $_POST['edit'];//updated status post from the form on the lower part of the page if ($text == NULL) { die(); } else { $fp = fopen ($status, "w"); fwrite ($fp, $text); fclose ($fp); } Here is the error for the page: Notice: Undefined index: edit in index.php on line 14 Line 14 where my $text variable is defines. how do i get it to not right unless the form has been submitted???
  17. Ok, i've figured out what to do. I made 2 files. one for the form that posts to the second. the second gets the info from the DB and then echos it into a meta refresh to the location with a 1 second refresh time. it works, not slick, but will do for now. The Header() tag wouldn't work because it was a case of the chicken before the egg. Header() stops all the rest of your script from going into action, so the query to the db never runs and gets the variable needed to do the job of redirection. Thanks for your assistance everyone, you lead me in the right directions.
  18. the header isn't working. I looked it up and I see why not. the problem is that header() is the only thing that should run and then the rest of the page dies. Let me break this down for everyone. I have a form that queries the DB for a user, I get his ip as a result also, but as i get the result i want that Ip address passed to the browser as the site it should go to. no link clicking, almost like the google "i'm feeling lucky" button. straight to the result. I had a hobo's way to do it, and maybe the only way. send the ip result to a page that redirects to that address. is that possible? I've tried to pass the variable over url. didn't work.
  19. I was reading about the header() tag. Dezkit? Where does this go? My form is a hidden pop out JavaScript box. Sorry I don't have the code handy for that. I'm on my iPod right now. Should I put it after the query? How do I call it into action
  20. Thanks for your help, but won't this just give a link in the browser window? I'm really looking for someway to bypass the user and go to the link.
  21. OK, here is my scenario. I'm working on a method to find specific users ip address within a vpn. I have the DB all set to test, and I've got the search and form working correctly as I can echo the correct record. Now I'm looking for a way to pass the ip address that results straight to the browser and have it go there. Is that possible? I've been searching with no luck. All i can find is people who want to take the address bar information, not send to it. thanks for your help, if any. $terms = $_POST["terms"]; $query = "SELECT fullname, ownip FROM userdata WHERE fullname ='$terms'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "user :{$row['fullname']} <br>" . "ip : {$row['ownip']} <br>" ; }
  22. MadTechie, you're my hero. thanks it worked like a charm. Essentially I'm pulling forward Items that a user has available for others to view. The progress bar goes along with each separate item. Thanks for the Help.
  23. ok, I tried it, but basically i need it to repeat with each result posted from the array. The Include_once worked as far as getting rid of the error, but not the result I'm looking for. I wondering if I should join the table needed for the progress bar and build it into the array. That would be the hard way as this is not the only page I need this to work with. Is there any other options???
  24. I'm a big newb so i need some help with an include i'm trying. the include works inside of an array (maybe that is part of the problem). It is to call up a progress bar that coincides with the items listed in array. Here is the page it with the include. It's sloppy but aside from my problem it works: $sessionid = $_SESSION['userid']; } //$join = "SELECT items.*, image.* ". COPIED FORMAT // "FROM items, image ". // "WHERE items.imageid = image.id". // "AND items.userid = $sessionid"; $join = "SELECT items.*, image.* FROM items, image WHERE items.imageid = image.imageid AND items.userid = $sessionid"; ?><strong><? $PicSQL = mysql_query($join)or die(mysql_error()); while ($row=mysql_fetch_array($PicSQL)) { echo $row['name']; ?><br><? echo $row['descrip']; ?><? //echo $row['imagename']; ?><br><? echo "<img src=\"/dev/uploads/". $row['imagename'] ."thumbnail\">"; //echo $row['imageid']; ?><br>Price: <? echo $row['price']; ?><? $itemImg = $row['imageid']; $itemid = $row['id']; include ("raffleprogresstemp.php");?><hr><?[/font] } Here is the included page: <? $progSQL = mysql_query("SELECT items.*, tickets.* FROM items, tickets WHERE items.id = tickets.item AND items.id = $itemid"); while($row6=mysql_fetch_array($progSQL)){ $price = $row6['price']; //echo $row['price']; $number=mysql_num_rows($progSQL); //echo "total tickets sold= ". $number;?><br><? } //$query = mysql_query("SELECT * FROM student"); EXAMPLE //$number=mysql_num_rows($query); //echo "Total records in Student table= ". $number; function progressBar($price, $number) This is the Line 15 of the Error { $percentage=$number / $price * 100; echo '<table cellpadding=1 cellspacing=1 border=1 width=100><TR><td><img src="images/bar.jpg" height=10 width='.$percentage.'></td></TR></table>' ; } progressBar($price, $number); ?> The Error Message is: Fatal error: Cannot redeclare progressbar() (previously declared in /home/.tarry/bampow/bampow.com/dev/raffleprogresstemp.php:15) in /home/.tarry/bampow/bampow.com/dev/raffleprogresstemp.php on line 15 Please Help me out.
×
×
  • 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.