Jump to content

miffe

Members
  • Posts

    84
  • Joined

  • Last visited

Previous Fields

  • Languages
    Qbasic, Visual Basic, NET, PHP, HTML, CSS, C++, JAVA

Contact Methods

  • MSN
    mike.war@gmail.com
  • Website URL
    http://www.lemiffe.com
  • ICQ
    0

Profile Information

  • Location
    Mexico
  • Interests
    Music, Programming, Web Design, GFX Design

miffe's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Ok you are right, I won't use PHP for no reason, I'll try the AJAX method but it's a bit complicated, here is my issue:in the 'editor' where I want to update the comboboxes I have the following<?php echo "<head><title>DIVAonline [Editor de Remisiones]</title>"; echo "<link rel='stylesheet' href='resources/links.css'>"; echo "<META HTTP-EQUIV='Cache-Control' CONTENT ='no-cache'>"; echo "<script src='updater.js'></script></head>"; //I have updater.js in the same directory. echo "<form action='rem_modelos.php' method='post'>"; //--- Select ---// echo "Modelo: <SELECT name='idModelo' STYLE='width: 146px' onchange='showUser(this.value)'>"; include("resources/config.php"); //connectarse a la base de datos $result = mysql_query("SELECT * FROM modelos ORDER BY idModelo;"); $y = 0; while($row = mysql_fetch_array($result)) { $idn = $row['idModelo']; $idt = $row['nombre']; echo "<OPTION value='" . $idn . "'>" . $idt . "</OPTION>"; $y++; } mysql_close($con); echo "</select><br>"; echo "</p><p><span id='txtHint'>as</span></p><p align='right'>";?> Then in the updater.js I have the following: var xmlHttpfunction showUser(str){ alert ("function working")xmlHttp=GetXmlHttpObject()if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="updater.php"url=url+"?q="+strurl=url+"&sid="+Math.random()xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true)xmlHttp.send(null)}function stateChanged() { alert ("statechanged working")if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } }function GetXmlHttpObject(){var xmlHttp=null;try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } }return xmlHttp;} And finally in updater.php I have this: <?php$q=$_GET["q"];include("resources/config.php"); //connect to database. This code works, Im sure of it. (tested)$sql="SELECT modelosColores.idColor, modelosColores.idModelo, colores.colorFROM modelosColoresLEFT JOIN coloresON modelosColores.idColor = colores.idColorWHERE idModelo = '".$q."'";$result = mysql_query($sql);echo "Color: <SELECT name='idColor' STYLE='width: 146px'>";while($row = mysql_fetch_array($result)) { $idn = $row['idColor']; $idt = $row['color']; echo "<OPTION value='" . $idn . "'>" . $idt . "</OPTION>"; }echo "</select><br>";mysql_close($con);?> Now, when I run it... I don't get anything in where it should have been... when I change variables in the drop down box nothing happens, not even the 'alerts' i put in the javascript code, the functions are not running.. I've not a clue where I went wrong :\helppppppp?
  2. The more I learn about server scripting, the more I realize that everything is interconnected, to do this thing you use this language, but if you want this too you have to use this and this language. It's not all about "HTML" and "PHP" anymore, but more like "HTML+PHP+JavaScript+MySQL+CSS+XML+etc..."Would you suggest I learn Javascript before continuing? I would have never considered learning JavaScript, I always thought of this a dying language and that PHP could do the same and more, I guess I was completely wrong. I mean, JS and PHP are both scripting languages so automatically I thought that either would do :\
  3. I had never heard of DOM before, what exactly is this? I know it's the HTML Document Object Model, which "defines a standard way for accessing and manipulating HTML documents." but what does this mean?I know HTML I've been using it since 6-7 years ago, and I know a bit of PHP (quite enough) and MySQL, but I never heard of DOM. Is this like the standards and references to be able to change HTML from other pages and scripts? or what exactly is DOM used for?
  4. I checked it out, the problem is that in this example it displays how to just change something based on predefined values, in this case the example makes the text uppercase on change... In my case I have to access the database everytime there is a change, pull out the values, update the form and keep it viable to make the 'submit' button grab all values and make the INSERT properly.Thats why I started thinking it might be AJAX and not just simple Javascript, because I did think about the onchange event but now somehow I don't think it's that simple
  5. Ok here's the problem...Say I have a soldProducts.php page in which it displays all products currently sold in one invoice to a client. This is an 'edit & update' page in which we display the products on the invoice, and you can add more from the product database, the products have several specifications that can be changed, lets say...product "E-1" can be in colors "A, AB, BA, B"product "E-2" can be in colors "A, B"product "E-3" can only be in "B"I have the relationships in MySQL relational tables, my problem is this: I want to display a form which displays the products in the first combo box (idProduct) and after selecting a product the second combobox will display the available colors (idColor) and at the same time a text box will update with the default product price (name:price). I know I probably will have to involve AJAX, I read a bit of the tutorial but couldn't find it as easy as to implement it with my specifications. The point is that I need to keep the html form values because there will be a SUBMIT, so I'm not sure how to do this, in the AJAX example on the tutorial, after changing the values in the textbox in the 'suggest' example, it would change some text on the page, but not an actual other combobox. I could implement a simple replace but as I have to extract values from a DB each model change, I think it would be best to use AJAX right?Can anyone tell me a quick way to get through this because I am really breaking my head on all this script... 400 lines so far and it just gets quite confusing, I've never used AJAX before and I can't say I'm a PHP pro but I get my way around :)Any help would be REALLY appreciated as I have to get this job done soon,Thanks again, Miffe
  6. miffe

    Insane Script

    Ok well, let's say, I was inserting all values from older invoices into the system but then i saw they were mixed up, so I decided to put them all in as they were, the problem is that the ID is the principal ordering value, I can order by Date but I prefer the ID to be the main one as each new invoice uses the 'next' id number, and the dates are a bit mixed up consecuently, for example:invoice 1 has a 2005 dateinvoice 2 has a 2004 dateif I order by date thats fine, but what if I want to order by ID which is the default...so I decided to make this script.MY solution to what you said is do something like this, I know consistency problems would occur but what if I put all id's to 1,000,000 + idnumber, as well as in all other related tables 1,000,000 + idnumber... then rename all to the consecutive order..or something like that,im not sure if i explain myself but any help would be appreciated,thx... miffe
  7. miffe

    Insane Script

    Let me see if I understand...1. Create temporary table 'invoiceTemp'2. Copy all data from invoices to invoiceTemp (auto-increment the id) and a row to specify the old id number3. Loop through new invoiceTemp resultset and change all id's on 'invoices' to new values where old id # = invoice actual id #4. Loop through 'lend' and 'sale' resultsets and change all id's on them the same was as the latter step.Is this all? or did I do something incorrectly?(edit: BTW I've never used stored procedures, thats why I thought PHP would be an easier script to make, but changing large numbers of records might make it unstable right? or wont it affect?)
  8. miffe

    Insane Script

    Here I have an odd script to do if anyone is up to the task for helping me a little bit... it's nothing too hard but it involves a bit of PHP and SQL, I considered it appropriate in posting it here because the script itself can be a PHP script.Basically I have 3 related tables in an mySQL db: Invoices, Sale, Lend.Invoices: id | name | date--------------------29 | bla2 | 2003/07/051 | bla | 2004/02/0150 | ok | 2004/04/20134 | new1 | 2005/03/024 | test | 2007/03/29 Sale: idSale | idPart | idInvoice1 - 03 - 12 - 09 - 13 - 20 - 294 - 01 - 295 - 94 - 1346 - 34 - 1347 - 15 - 134 Lend: idLend | idPart | idInvoice | time1 - 23 - 502 - 19 - 503 - 40 - 504 - 81 - 505 - 33 - 46 - 99 - 47 - 00 - 4 So basically you have an invoices box, which might have been for sales or for parts being lent for a period of time... my problem is that in the invoices section the id's are not ordered... I dont want an ORDER BY nonsence, that's not my problem... I mean in relation to the date... lets suppose I had 200 invoices and many of them where deleted or skipped or not introduced into the system and only those where remaining with different dates... now I want to REarrange them according to the existing numbers.In this case: I only have 5 invoices, so I need to renumber them 1,2,3,4,5... but I also have to change all relationships in 'sale' and in 'lend' first... so I guess I have to create a buffer of some sort, an array? or something where I display the old value and the new ordered value, then change all in sale and in lend, and afterwards change the invoice ID's...Does anyone have an idea on where to start? some code? or something ^^Thanks a lot,Miffe
  9. miffe

    ORDER BY (manually)

    mhhhh oooook, its just that ive already got more than 45 tables in my DB and didn't want to add another one...I might instead better just do the sorting manually with php code ^^ that should work right?
  10. miffe

    Prevent SQL injections?

    use php replace command for that.I have a question concerning this:As you can insert SQL queries into textboxes when not using mysql_escape_string by terminating the SELECT query in the textbox in some systems... wouldnt it be easier to do a function to check if there is an SQL query written in the textbox and if there is note that this is an attempt at sql injection, notify the user that this is impossible and just not allow login or the function the person is trying?I mean, no idea what I'm saying really... just a thought.
  11. well i guess you'd have to post us your php code for the register function for us to help you out, you are giving us too little information to work on. just do an INSERT with the propper values and that should work, taking into consideration the auto_inc.- miffe
  12. miffe

    ORDER BY (manually)

    Lets say I have a field called operation which holds values like (/,+,- and *) but as it has no id tag or index, and I don't want to make another table with the order of operations... is it possible to do a manual ORDER BY specifying which one goes first, then next, etc. ?thanks- miffe
  13. miffe

    easy inner join

    Excellent... thanks again Jesh!I was trying something very similar but for some reason it wasnt working for me, it strange just how a small symbol or character can mess everything up and take ages for one to notice it -miffe
  14. miffe

    easy inner join

    excellent, thanks, I got the hang of that now...Actually I've got one more problem I'd like to discuss... this involves a bit of a more difficult join, lets say I have a table which links to other tables directly with different id numbers, but one of those id's links to another table which is a 'many-to-many' relationship table that links to another one... and I want to display data from the first table and from the third.Ive found it quite difficult... lets say I have the following:modelos-------idModelonombreidProcesoidCategoria.procesos--------idProcesonombreProceso.categorias----------idCategorianombreCategoria.coloresModelos--------------idModeloidColor.colores-------idColornombreColor Basically I want to show the info from modelos, and inner join to the nombreProceso and nombreCategoria and at the same time show me all the nombreColor from the relationships in coloresModelos...Final output should be something like:idModelo | nombre | nombreProceso | nombreCategoria | colorin case there was no color specified in the relationship it just wouldnt come up, thats easy... with a left join... but I just cant get the hang of showing the colors :\I did one once with access and it was easy, but I have Access produces SQL and right now im coding all myself in php - mysql for this system..Any help?Thanks - Miffe
  15. miffe

    Date

    I prefer to use the interfase to solve that, if you are using php you might consider using time and date functions, or like ways in any other language such as perl, asp, java, js, etc... and just insert the date into a datetime field in mysql or whatever DB system you might be using.
×
×
  • Create New...