Jump to content

nullpoint81

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Everything posted by nullpoint81

  1. Just looking for a script, or maybe someone that has seen one similar to this. I'd like to find a script that copies data from one textarea to another using one or multiple checkboxes.
  2. Well, I guess I can't necessarily visualize what you mean by this, although looking at the way that a CMS...let's say Wordpress, for example, handles data I do agree. I may not be doing this the most efficient way possible. If you're interested, I could let you see what I'm working on.
  3. That sounds like the case, indeed, for these reasons: [*]I have empty rows throughout the DB (since some corresponding times do not have anything valuable to use in the way of data). [*]The query is essentially saying match the id from the $day.$day$time table to the corresponding id on the sip_data table. I've tried changing up the query a bit, tried a BETWEEN in place of AND, all to no avail. When you say "echo out the SQL", what do you mean exactly? Thanks for the help.
  4. Full page code: <?php $dbhost = "llllocalhost!"; $dbuser = "lll"; $dbpass = "lll"; $dbname = "lll"; //Connect to MySQL Server $link = mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $id = $_GET['id']; $name = $_GET['name']; $zip = $_GET['zip']; $server_url = $_GET['server_url']; $day = $_GET['day']; $time = $_GET['time']; $time1 = $_GET['time1']; $type = $_GET['type']; // Escape User Input to help prevent SQL Injection $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $zip = mysql_real_escape_string($zip); $server_url = mysql_real_escape_string($server_url); $day = mysql_real_escape_string($day); $time = mysql_real_escape_string($time); $time1 = mysql_real_escape_string($time1); $type = mysql_real_escape_string($type); //build query $query = "SELECT * FROM $day,sip_data WHERE sip_data.type='bar' AND $day.id=sip_data.id AND $day.$day$time <=> $day.$day$time1 ORDER BY zip ASC"; //Execute query $qry_result = mysql_query($query) or die(('No Results')); //Build Result String $places = array(); while($row = mysql_fetch_array($qry_result)) { $places[$row['zip']][$row['server_url']] = $row['name']; } foreach ($places as $place => $d) { echo "<table id=query_result align=left>"; echo "<tr>"; echo "<th id=query_result_zip>$place</th>"; echo "</tr>"; foreach ($d as $n => $r) { echo "<tr>"; echo "<td id=query_result_name><a href=$n rel=ajaxDiv>$r</a></td>"; echo "</tr>"; } } echo "</table>"; ?> Carryover from previous thread, this is baffling me yet again.
  5. I really do need a pro at this point. Not trying to bump or be a Bueller, just trying to get this resolved before I smoke the entire pack.
  6. It's good that you took the time to do that. I already did that once on my own server (just posting code without thinking) and left it up for maybe 4 seconds. But seriously, how...can...what? What is wrong with some people? Ok, no.
  7. Kinda did already. Hope you check this thread soon sir. Since he went 6 hours without noticing his db creds in public, I killed them. OP, you absolutely 100% must change your database password the instant you read this. Right now, stop reading and go change your password. The cake is a lie. And so is your website...well, now. I'm still looking for help with my own damn issue, but keep checking back to see the drama unfold. Oh dear, my life.
  8. Kinda did already. Hope you check this thread soon sir.
  9. Yeah, ouch. You've set yourself back a bit with this post... Does your host give you a name prefix at all? (for example - my host adds the generated username, lets say "ithaca_", and then adds the name of the domain - so it would be ithaca_randomwebsite for the username). The password would come back as "No" since the username "may" be incorrect...I would try the prefixed name, or if you have CPanel, look in the MySQL DB wizard as the correct username (if there eve is one, mind you) should be listed there. But yeah, you (hopefully) will pull this info offline before the Russian viagra squad gets hold of it.
  10. One other thing I should mention - the $day, $time, $time1 are variables populated by a form (ajax), so they must be included for basically anything to work. It's essentially a form that takes the $day (monday-sunday) and $time,$time1 (military - 0800 to 0200). The query is supposed to search for results in between $time and $time1 (whatever the user selects). Here's the current query code (added a filter for $type): $query = "SELECT * FROM $day,sip_data WHERE sip_data.type='bar' AND $day.id=sip_data.id AND $day.$day$time <=> $day.$day$time1 ORDER BY zip ASC"; The ASC is kind of redundant, I know. I'm still curious if this is an issue with the query itself or the way the DB is set up...puzzled/mindblown.
  11. Upon further testing the issue still remains. It's very...strange. The LEFT JOIN and INNER JOIN didn't work - actually gave the same exact results. I was looking at what tables had data in my testDB and discovered that this query is actually returning all results (obviously, since there is a *). The really weird part is that when it hits data in a table, it will actually exclude that result entirely. So it's kinda doing the opposite of what it's supposed to be doing (in some cases)! Another example is...let's say I have a partial match - data is on 1/2 of the query but not on the other half (1/2 of the time range, for example). It will show that result as if it was a full match.
  12. This may even be more of a SQL question, but you guys are good so I thought I'd give you a crack at this first. I have this query: $query = "SELECT * FROM $day,sip_data WHERE $day.id=sip_data.id AND $day$time<=>$day$time1 ORDER BY zip ASC"; Which searches between different tables on the same database, basically matching up the $id on tables and giving the results. Funny thing is, when the search is executed, it displays the name of the sip.data table even if the row is completely empty (i.e. - if the matching $day$time row is completely empty). I suspect this is because when something is added to the DB, an $id (AUTO_INCREMENT) is added to all tables and rows. I've got all of the rows set to NULL by default, TEXT as type, except for the $id on each table, which is AUTO_INCREMENT. Any suggestions?
  13. Ok, I just figured it out...such a stupid thing. The <table> began outside of the "outer" loop - changing the starting position of that tag actually gives me the result I was looking for. Just for future reference for other newbs, here's the code change: $places = array(); while($row = mysql_fetch_array($qry_result)) { $places[$row['zip']][$row['server_url']] = $row['name']; } echo "<table id=query_result align=left>"; foreach ($places as $place => $d) { echo "<tr>"; echo "<th>$place</th>"; echo "</tr>"; foreach ($d as $n => $r) { echo "<tr>"; echo "<td><a href=$n rel=ajaxDiv>$r</a></td>"; echo "</tr>"; } } echo "</table>"; ?> Produced this result: $places = array(); while($row = mysql_fetch_array($qry_result)) { $places[$row['zip']][$row['server_url']] = $row['name']; } foreach ($places as $place => $d) { echo "<table id=query_result align=left>"; echo "<tr>"; echo "<th>$place</th>"; echo "</tr>"; foreach ($d as $n => $r) { echo "<tr>"; echo "<td><a href=$n rel=ajaxDiv>$r</a></td>"; echo "</tr>"; } } echo "</table>"; Produced this result: And yes, technically it is producing several tables instead of one with different columns, but that's totally fine actually. I'm cool with that. Thanks for all the help everyone, will mark this as "solved".
  14. Because of the way I have the site built, I'm not able to view source on that particular div. But yeah, I've tried moving the </table> around all over the place, tried adding a <br> in here or there - it's just baffling me.
  15. I've tried that, and it basically just shortens the loop to one iteration, then dumps everything else outside of the table.
  16. Haha, that was actually me on a different forum: http://www.phphelp.com/forum/index.php/topic,14978.0.html That's pretty funny! jcbones actually provided a snippet closest to what I am looking for, but I'm still trying to figure out a way to keep the loop going until all the information has been inserted, THEN insert the echo "</table>"; to end the table.
  17. My question is basically this: If I'm building a submission form - which places info into my DB via a mySQL query (INSERT INTO) - is there also a way to reference the id that it is creating? The form is set to just dump raw data into a database - each submission enters data into at least 8 DB tables which are all tied together by an $id row in each table. My query references those $id rows in each table to build a query. After each query is completed, a unique url (which is stated by the submitter in the form of /example/someotherword/) is generated. I need to find a way to place some sort of script within a page that displays the results based on each $id. So, lets say that the url is clicked, it would take you to a page that displays the results - but only does so based on the reference to that urls unique $id within the table. I'll provide code once I get home, but if you guys have any ideas that would be great.
  18. Ok, one other thing I noticed is that the <table> doesn't close, so I threw an echo "</table">; In at the end and it's pushing everything horizontal now, which is great except it isn't including everything within the html table. I'm thinking there must be some simple code that will allow the script to dump all of it's results, then add the echo "</table">; in at the end after everything is finished. Thanks for all the help guys, you've really taught me something today.
  19. Yeah, I just tried both snippets and the last one is closest, only bad part is that it's placing all results into one column. Blacknight's code was truncating the names and giving incorrect urls. But hey, way better than what I had before. Lemme see if I can figure out a way to start a new column with each $zip.
  20. Hey all, first post to this site. I'm somewhat new to PHP, so bear with me - this might be an easy question, it might not be. Just looking for a little help. Basically, I have a query which takes commands from a form through AJAX (day, time, time1). The query executes a wildcard on a table named sip_data, searches for linked $id (so if $id=3, for example in multiple tables, it spits out the $name, $zip in a div). Here's the code: <?php $dbhost = "localhost"; $dbuser = ""; $dbpass = ""; $dbname = ""; //Connect to MySQL Server $link = mysql_connect($dbhost, $dbuser, $dbpass); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query String $id = $_GET['id']; $name = $_GET['name']; $zip = $_GET['zip']; $server_url = $_GET['server_url']; $day = $_GET['day']; $time = $_GET['time']; $time1 = $_GET['time1']; // Escape User Input to help prevent SQL Injection $id = mysql_real_escape_string($id); $name = mysql_real_escape_string($name); $zip = mysql_real_escape_string($zip); $server_url = mysql_real_escape_string($server_url); $day = mysql_real_escape_string($day); $time = mysql_real_escape_string($time); $time1 = mysql_real_escape_string($time1); //build query $query = "SELECT * FROM $day,sip_data WHERE $day.id=sip_data.id AND $day$time<=>$day$time1 ORDER BY zip ASC"; //Execute query $qry_result = mysql_query($query) or die(('No Results')); //Build Result String while($row = mysql_fetch_array($qry_result)) { echo "<table id=query_result align=left>"; echo "<tr>"; if($zip = $row[zip]); echo "<th><b>$row[zip]</b></th>"; echo "</tr>"; echo "<tr>"; echo "<td><a href=$row[server_url] rel=ajaxDiv>$row[name]</a></td>"; echo "</tr>"; echo "</table>"; } echo $display_string; ?> Basically, my issue with this is that some of the results within the sip_data DB will have zip codes that repeat. The current code prints out each results with the zip code and name - here's an image of a sample result: What I would like to do is avoid repeating the zip code and just group the results under each zip code, kinda like this: 55408 55412 55423 --------- ------------ ---------- example example example example example example Any help would be greatly appreciated. I feel like I'm so close to the answer, but just need a little guidance. Who knows, I might be way off. Thanks in advance!
×
×
  • 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.