Jump to content

Recommended Posts

UPDATE models SET modmanf='".forSql($_POST["modmanf"])."', modmod='".forSql($_POST["modmod"])."', old='".forSql($_POST["old"])."', modpiclar='".forSql($_POST["modpiclar"])."' WHERE modid='$modid'");

 

 

This is my update script from a edit page in my site and it works fine

@Erick020: if you want 'urgent' help, then post in the freelancing forum and offer something in exchange for an 'urgent' response.

 

The information you provided isn't enough for anyone to offer sensible advice.  What is "I get this" nsupposed to mean to anyone?  Give us some logical information; explain what "does not work" actually means; you could even post some of your code.  Without a lot more information, you'll be waiting a long time for a solution.

@Erick020: if you want 'urgent' help, then post in the freelancing forum and offer something in exchange for an 'urgent' response.

 

The information you provided isn't enough for anyone to offer sensible advice.  What is "I get this" nsupposed to mean to anyone?   Give us some logical information; explain what "does not work" actually means; you could even post some of your code.  Without a lot more information, you'll be waiting a long time for a solution.

 

Sorry for the "urgent", I didn't mean it that way...

Anyway, I already sent a post "Multiple Update" but get no answer.

 

so if you want take a look and tell me what I am doing wrong... please easy explaination... and exemple... I am no expert !!  LOL !!

 

Thanks a lot

UPDATE models SET modmanf='".forSql($_POST["modmanf"])."', modmod='".forSql($_POST["modmod"])."', old='".forSql($_POST["old"])."', modpiclar='".forSql($_POST["modpiclar"])."' WHERE modid='$modid'");

 

 

This is my update script from a edit page in my site and it works fine

 

Thank a lot....  I gonna try that way... and will let you know.

$q = "select * from TABLE_0

 

WHERE Sold = 'NO'

AND Zip LIKE '$Zip1$Zip2%'

ORDER BY Date asc

LIMIT $Leads_H ";

 

if(!($res = mysql_DB_query($DB, $q)))

die("ERROR");

 

$res = mysql_db_query($DB, $q);

$numberOfRows=mysql_num_rows($res);

 

while ($i > $Leads_H) {

$Q_ID=mysql_result($res,$i,"Q_ID");

echo "<input type='hidden' name='".$r["Q_ID"]."' value=Q_ID[$i]>";

 

}

while ($r=mysql_fetch_array($res)){

$Q_ID = $_POST[Q_ID][$i];

 

echo "<input type=hidden name=Q_ID[$i] value=".$r["Q_ID"].">

<td align=left class=black>".$r["Name"]."</td>

<td align=left class=black>".$r["Zip"]."</td>";

++$i;

 

}

 

echo "<a href=Command.php>ORDER</a>";

 

NOTE : THIS WORKS OK, I GET <input type=hidden name=Q_ID[0] value=6>

<input type=hidden name=Q_ID[1] value=9>

<input type=hidden name=Q_ID[2] value=17>

 

On the next script (Command.php) I run:

 

$q ="insert into TABLE_1 (Company_Name, A2, A3) values ('$Company_Name', '$A2', '$A3')";

 

and then I need to update an other table:

 

$q = "update TABLE_0 set Sold='YES',Company_Name='$A'

 

WHERE

 

'Q_ID[$i]' = 'Q_ID[$i]' LIMIT $Leads_H";echo $q;

 

while ($r=mysql_fetch_array($res)){

$Q_ID = $_POST[Q_ID][$i];

}

 

It seems it doesn't recognize the ID of Q_ID

In my exemple:

<input type=hidden name=Q_ID[1] value=9>

<input type=hidden name=Q_ID[2] value=17>

it supposes to update Q_ID where the ID is 9 and 17...

What is the error returned? And in the future can you use the

[ p h p ]

<? ?>

[ / p h p ]

so we can visualise some of the markup.

 

No error is returned, just nothing happends.

Anyway, this is what I need to do:

 

I first collect some info from TABLE_0... echo on the page:

echo "<input type=hidden name=Q_ID[$i] value=".$r["Q_ID"]."> 
<td align=left class=black>".$r["Name"]."</td> 
<td align=left class=black>".$r["Zip"]."</td>"; 

This part works as I get for exemple <input type=hidden name=Q_ID[0] value=9>

<input type=hidden name=Q_ID[1] value=17>, but then I must update the TABLE_0 and change some data where the ID (Q_ID) have been called on the first page, is this exemple ID 9, ID 17.

This code doesn't work:

$q = "update TABLE_0 set Sold='YES',Company_Name='$A' 
WHERE 

'Q_ID[$i]' = 'Q_ID[$i]' LIMIT $Leads_H"; 

while ($r=mysql_fetch_array($res)){ 
$Q_ID = $_POST[Q_ID][$i]; 

 

It just update the first ($Leads_H) rows of the table, no matter the selected ID's (Q_ID).

I guess the statement is wrong, but I think the best is to rewrite the right codes without trying to correct my codes... so just forget what I did, and if you now understand what I need to do, please help me with the right statement.

 

I'm still confused about all this stuff.

 

Are there two separate scripts here - one to get database info and populate a form, and another to UPDATE a record?  How are these form data ever acquired by the script that's supposed to update the database?

 

How about posting more (complete) code - placed between CODE tags, please - to make the problem statement clearer. An explanation of what you are hoping to achieve would help.  Quoting a bizarre query that doesn't work isn't helpful in understanding your problem.

I'm still confused about all this stuff.

 

Are there two separate scripts here - one to get database info and populate a form, and another to UPDATE a record?  How are these form data ever acquired by the script that's supposed to update the database?

 

How about posting more (complete) code - placed between CODE tags, please - to make the problem statement clearer. An explanation of what you are hoping to achieve would help.  Quoting a bizarre query that doesn't work isn't helpful in understanding your problem.

 

OK.. you'r right.... I just sent you an email with the original scripts.... and I hope a clear explaination.

 

Cheers,

Erick

No,no. Post your code and explanations in this thread. I don't want the code emailed to me.  Far better to have it all here so that all the members can share in solving it and learn from the solution.

 

Hypotheek_A.php = where you select the number of rows you want.

Show_Leads_H.php = the list of the selected rows

Command_Leads_H.php = the script where I need to insert into table BESTELLING some data (that works OK) and I need to update the table HYPOTHEEK and change some data where the row ID (Aanvraag_ID) have been selected on script Show_Leads_H.php

 

FIRST SCRIPT: Hypotheek_A.php

 

$q = "select * from HYPOTHEEK
   
  WHERE Sold = 'NO'
  AND Zip LIKE '$Zip1$Zip2%'
   ORDER BY Date_Aanvraag desc
   
              ";
              
              if(!($res = mysql_DB_query($DB, $q)))
           die("query failed.");
           
           $res = mysql_db_query($DB, $q);
        $numberOfRows=mysql_num_rows($res);

        if ($numberOfRows>0){

        if ($r=mysql_fetch_array($res)){
        
        $var++;
    
    echo "<head>
<title>LEADS</title>
<link rel=stylesheet href=Erick.css>
</head>
<body leftmargin=0 topmargin=0>
<table width=800 border=1 cellspacing=5 cellpadding=5 align=center>
  <form method=post action=Show_Leads_H.php?A=$A&&Zip1=$Zip1&&Zip2=$Zip2&&Kind=$Kind&&NOR=$numberOfRows name=Leads>
  
  <tr>
  <td align=center valign=middle><b>Er zijn $numberOfRows leads die aan uw zoekopdracht voldoen</b></td>
  </tr>
  <tr>
  <td align=center valign=middle>Hoeveel leads wilt U bestellen? <input type=text name=Leads_H size=2 maxlength=2></td>
  </tr>
  <tr align=center>
  <td align=center class=black><input type=reset name=Reset value=HERSTEL> <input type=submit name=Submit value=TONEN></td>
  </tr>
  <tr>
  <td align=center class=black><a href=javascript:history.go(-1)>TERUG</a></td></tr></form>
  ";
    
    }
    
    }
    else {
    
    echo "<head>
<title>LEADS</title>
<link rel=stylesheet href=Erick.css>
</head>

<body leftmargin=0 topmargin=0>
<table width=800 border=0 cellspacing=5 cellpadding=5 align=center>
  
  <tr>
  <td align=center valign=middle><b>Er zijn helaas nog geen aanmeldingen die voldoen aan uw zoekopdracht</b></td></tr>
  <tr>
  <td align=center class=black><a href=javascript:history.go(-1)>TERUG</a></td>
  </tr>";
    
    
    }

 

SECOND SCRIPT: Show_Leads_H.php

 


$q = "select * from AFNEMER
   
   	WHERE Afnemer_ID = $A
              
              ";
              
              if(!($res = mysql_DB_query($DB, $q)))
           die("query failed.");
           
           $res = mysql_db_query($DB, $q);
        $numberOfRows=mysql_num_rows($res);

        if ($numberOfRows>0){

        while ($r=mysql_fetch_array($res)){
        
       	if ($Leads_H == "")
	die("<html>
<head>
<title>LEADS</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<link rel=stylesheet href=Erick.css>
</head><body leftmargin=0 topmargin=0>
<table width=100% border=0 cellspacing=19 cellpadding=19 align=center>
  <tr> 
    <td align=center class=black>INVOER ONJUIST<BR><BR><BR><a href=javascript:history.go(-1)>TERUG</a></td>
  </tr>
</table>
</body>");

if ($Leads_H == "0")
	die("<html>
<head>
<title>LEADS</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<link rel=stylesheet href=Erick.css>
</head><body leftmargin=0 topmargin=0>
<table width=100% border=0 cellspacing=19 cellpadding=19 align=center>
  <tr> 
    <td align=center class=black>INVOER ONJUIST<BR><BR><BR><a href=javascript:history.go(-1)>TERUG</a></td>
  </tr>
</table>
</body>");

if ($Leads_H > "$NOR")
	die("<html>
<head>
<title>LEADS</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<link rel=stylesheet href=Erick.css>
</head><body leftmargin=0 topmargin=0>
<table width=100% border=0 cellspacing=19 cellpadding=19 align=center>
  <tr> 
    <td align=center class=black>INVOER ONJUIST<BR><BR><BR><a href=javascript:history.go(-1)>TERUG</a></td>
  </tr>
</table>
</body>");

if (!ereg("^[0-9]{1}",$Leads_H))
	die("<html>
<head>
<title>LEADS</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<link rel=stylesheet href=Erick.css>
</head><body leftmargin=0 topmargin=0>
<table width=100% border=0 cellspacing=19 cellpadding=19 align=center>
  <tr> 
    <td align=center class=black>INVOER ONJUIST<BR><BR><BR><a href=javascript:history.go(-1)>TERUG</a></td>
  </tr>
</table>
</body>");


if (ereg("^[A-Za]{1}[0-9]{2}",$Leads_H))
	die("<html>
<head>
<title>LEADS</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<link rel=stylesheet href=Erick.css>
</head><body leftmargin=0 topmargin=0>
<table width=100% border=0 cellspacing=19 cellpadding=19 align=center>
  <tr> 
    <td align=center class=black>INVOER ONJUIST<BR><BR><BR><a href=javascript:history.go(-1)>TERUG</a></td>
  </tr>
</table>
</body>");

  echo "

<html>
<head>
<title>LEADS</title>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
<link rel=stylesheet href=Erick.css>
</head>

<body leftmargin=0 topmargin=0>
<table width=100% border=0 cellspacing=0 cellpadding=0 align=center>
  <tr> 
    <td> </td>
  </tr>
</table>
<p align=center class=black>LIJST LEADS HYPOTHEEK</p>
<table width=800 border=1 cellspacing=5 cellpadding=5 align=center>
  
  <tr>
    <td align=center class=black>NAAM</td>
    <td align=center class=black width=100>POSTCODE</td>
    <td align=center class=black width=100>PROVINCIE</td>
    <td align=center class=black width=150>AANMELDING</td>";
}
}


include "./setting.php";
   
global $DB, $DBUSER, $DBPASSWORD, $UserName, $Password, $User_ID, $row, $res, $Log;

$dbconn = mysql_connect("localhost",$DBUSER, $DBPASSWORD);


$Datetime=time();
$DT1=mktime($Month,$Day,$Year);
$DT2=time("H","m","s");
$i = 0;
$Aanvraag_ID[$i]= $_POST[Aanvraag_ID];

   $q = "select * from HYPOTHEEK 
   
  WHERE Sold = 'NO'
  AND Zip LIKE '$Zip1$Zip2%'
   ORDER BY Date_Aanvraag asc
   LIMIT $Leads_H
   
              ";


              if(!($res = mysql_DB_query($DB, $q)))
           die("ERROR");
          	 
           
           $res = mysql_db_query($DB, $q);
        $numberOfRows=mysql_num_rows($res);

       
while ($i > $Leads_H) {
$Aanvraag_ID=mysql_result($res,$i,"Aanvraag_ID");
echo "<input type='hidden' name='".$are["Aanvraag_ID"]."' value=Aanvraag_ID[$i]>";

}


        while ($r=mysql_fetch_array($res)){  
        $Aanvraag_ID = $_POST[Aanvraag_ID][$i];
        $var++;
        
  echo "<head>
<title>LEADS</title>
<link rel=stylesheet href=Erick.css>
</head>
<body leftmargin=0 topmargin=0>
<table width=800 border=1 cellspacing=5 cellpadding=5 align=center>
  
  <input type=hidden name=Aanvraag_ID[$i] value=".$r["Aanvraag_ID"].">
  <tr>
  <td align=right valign=middle width=25><b>$var</b></td>
    <td align=left class=black>".$r["Name"]."</td>
    <td align=center class=black width=100>".$r["Zip"]." ".$r["Zip_A"]."</td>
    <td align=center class=black width=100>".$r["Province"]."</td>
    <td align=center class=black width=150>".date("d-m-Y",$r["Date_Aanvraag"])."</td>
  </tr>

</table>

</body>
</html>";
++$i;

}

echo"<p align=center class=black><a href=Command_Leads_H.php?A=$A&&Zip1=$Zip1&&Zip2=$Zip2&&Kind=$Kind&&Leads_H=$Leads_H name=Leads_H1>ORDER BEVESTIGEN</a> - <a href=javascript:history.go(-1)>ORDER WIJZIGEN</a></p>";

 

THIRD SCRIPT: Command_Leads_H.php

 

$q ="insert into BESTELLING (Afnemer_ID, Leads_Kind, Aantal, Betaald, Datetime)
    values ('$A', '$Kind', '$Leads_H', 'NO', '$Datetime')";echo $q;
    
while ($r=mysql_fetch_array($res)){  
        $Aanvraag_ID[$i]= $_POST[Aanvraag_ID];
        }
         

if(!$dbconn){
   die("Connection failed.");
}else

 {
	if(($res = mysql_DB_query($DB, $q))){

	$q = "update HYPOTHEEK set Sold='YES',Company_Name='$A', Date_Sold='$Datetime'

WHERE

'Aanvraag_ID' = 'Aanvraag_ID[$i]' LIMIT $Leads_H";echo $q;


	echo "

	<html>
<head>
<title>LEADS</title>
<link rel=stylesheet href=Erick.css>
<!-- Developed & Designed by Erick Le Maire / © 2007 - AANMELDINGSFORMULIER -->


</head>

<body topmargin=5>
<table width=100% border=0 cellspacing=0 cellpadding=0 align=center>
  <tr align=center valign=top> 
    <td><table width=580 border=0 cellspacing=25 cellpadding=25 align=center>
  <tr>
  <td align=center valign=middle class=black><b>$Ref24</b></td></tr>
  <tr><td align=center class=black>Bedankt voor uw aanmelding.<br>
  Een samenvatting is naar uw email adres opgestuurd<br><br>
  Wij zullen heel snel contact opnemen met U</td></tr>
    <td align=center valign=middle class=black><a href=# onClick=\"window.close()\">SLUITEN</a></td>
  </tr>

</table>";
}
}

 

These are the original scripts and I hope you now understand what I need to do.

The first script works fine, the second one too, though I think I am missing something to send to the third script, because in the third one, the insert part is doing fine, but the update does not work. It suppose to update the selected rows (Aanvraag_ID[0], Aanvraag_ID[1], Aanvraag_ID[2]... etc... depending on the number ($Leads_H) of the selected rows in the second script.

 

In advanced thanks to all for your help.

 

Cheers,

Erick

 

 

HYPOTHEEK, Company_Name, SOLD. Is this code for real, I mean real business, money? No offense but then you should hire someone with more coding skills at least for the time being. I need to ask you again how much you know about php and mysql and what the purpose of the scripts is.

First step in solving your problem I think is to get rid of all that redundant or wrong code, code like

if(!($res = mysql_DB_query($DB, $q)))

          die("query failed.");

         

          $res = mysql_db_query($DB, $q);

helping us to focus on the your problem.

 

HYPOTHEEK, Company_Name, SOLD. Is this code for real, I mean real business, money? No offense but then you should hire someone with more coding skills at least for the time being. I need to ask you again how much you know about php and mysql and what the purpose of the scripts is.

First step in solving your problem I think is to get rid of all that redundant or wrong code, code like

if(!($res = mysql_DB_query($DB, $q)))

           die("query failed.");

           

           $res = mysql_db_query($DB, $q);

helping us to focus on the your problem.

 

 

Sorry, but I don't understand anymore.... and this has nothing to do with business....

When I said this is the real code... I mean I didn't change anything.... just as I ve been asked to do...

it's just something for internal use... anyway.... first I have been told... codes are too short... now it's too long.......

 

Look... I don't understand what you don't understand.... I need to update several rows (with all the same name, but of course different ID numbers - Aanvraag_ID..... which i get in the second script in the form of Aanvraag_ID[0]=6, Aanvraag_ID[1]=17, etc...... where of course 6 and 17 are the Aanvraag_ID I need to update).

 

What is it now you don't understand?

And please tell me how important my level in php is in this matter...

Can you just please fix my script so I can learn at least something...

And I think that will be easier if you tell me now what is it you think I try to do so I can see if you understood wha I meant otherwise I will try to explain differently.

And please tell me how important my level in php is in this matter...

Can you just please fix my script so I can learn at least something...

And I think that will be easier if you tell me now what is it you think I try to do so I can see if you understood wha I meant otherwise I will try to explain differently.

To me it seems the code is copied piece by piece without understandig what it does.

How much do you know about php and mysql? And what is your goal?

I still think that. If you get an answer that seems to fix the current code you will copy that to your script and be done with it. important thing for you: it seems to work. For the next function you will ask again and again and again. But don't know what the code does. I'm a php beginner but I'm also an experienced c/c++ developer. And this is how your codes looks like.

anyway.... first I have been told... codes are too short... now it's too long.......
First we saw this can't be all code. There must be something missing. Now I see there is, let me call it dead code. Something you've copied because you didn't know what the meaning is and now has become meaningless or even wrong.

And this code grabbing is not how I understand a coding forum should work.

Fixing the current script therefor serves two purposes. i) Making a cleaner script. It's easier to work with clean code or the other way round: it getting more and more difficult to work with unclean, garbled code. We will also easier understand what you're trying to do und it will be much easier to incorporate changes.  ii) see if you're willing to learn and work with php or if you only want to grab code.

 

I would like to start with basic understanding of php and mysql

if(!($res = mysql_DB_query($DB, $q)))
           die("query failed.");
           
           $res = mysql_db_query($DB, $q);

For what reason do you use mysql_DB_query and therefor what does this code do?

If you can't answer this basic question I think you need a mysql tutorial.

And please tell me how important my level in php is in this matter...

Can you just please fix my script so I can learn at least something...

And I think that will be easier if you tell me now what is it you think I try to do so I can see if you understood wha I meant otherwise I will try to explain differently.

To me it seems the code is copied piece by piece without understandig what it does.

How much do you know about php and mysql? And what is your goal?

I still think that. If you get an answer that seems to fix the current code you will copy that to your script and be done with it. important thing for you: it seems to work. For the next function you will ask again and again and again. But don't know what the code does. I'm a php beginner but I'm also an experienced c/c++ developer. And this is how your codes looks like.

anyway.... first I have been told... codes are too short... now it's too long.......
First we saw this can't be all code. There must be something missing. Now I see there is, let me call it dead code. Something you've copied because you didn't know what the meaning is and now has become meaningless or even wrong.

And this code grabbing is not how I understand a coding forum should work.

Fixing the current script therefor serves two purposes. i) Making a cleaner script. It's easier to work with clean code or the other way round: it getting more and more difficult to work with unclean, garbled code. We will also easier understand what you're trying to do und it will be much easier to incorporate changes.  ii) see if you're willing to learn and work with php or if you only want to grab code.

 

I would like to start with basic understanding of php and mysql

if(!($res = mysql_DB_query($DB, $q)))
           die("query failed.");
           
           $res = mysql_db_query($DB, $q);

For what reason do you use mysql_DB_query and therefor what does this code do?

If you can't answer this basic question I think you need a mysql tutorial.

 

I used this code because I learned to do so some time ago, and if the database cannot be reached for what reason instead of to get a blank page I get this error so I know what's going on.

 

This is no copied piece by piece without understandig what it does, and I also read a lot abd tried different way of doing what i need to do before i start to write here.

If someone could show me an exemple that will help me to understand. This is how I learn... by seeing exemples...

Now I spent 4 days on this forum chatting instead of reading and learning codes... I really did expect something else.

Anyway if you still don't understand what I need to do, please let me know what is it you don't understand,

and please just forget all my code.... show me how I should do so I at least can learn somehting.

Do not think I just copy codes without understanding what it does... once I have an exemple that HELP me to better understand.

erick, as has already been pointed out - if you need urgent help or someone to write your scripts for you, then post in the freelance forum. This forum is for those that have made the effort and have become stuck with code they've already written.

 

Also - spamming the topic with several posts with nothing but your name in it in order to bump is one way of getting on the wrong side of people that would otherwise have helped - me included. DO NOT DO IT.

hmmm... you've made it very difficult to understand what you need.

 

I think you want to send ID's to a page that then run a query on them ID's, in that case (and taking in consideration it's local) you can just send them via GET. then putting the GET's into a variable and querying them.

www.yoursite.com/pagename.php?id=2

$id = $_GET['id'];

//Put Query Here (SELECT * FROM TABLE WHERE ID = $id)

 

i think you need to take a deep breath and explain what you need on your pages.

 

Sorry i couldn't help more.

 

Snooble

hmmm... you've made it very difficult to understand what you need.

 

I think you want to send ID's to a page that then run a query on them ID's, in that case (and taking in consideration it's local) you can just send them via GET. then putting the GET's into a variable and querying them.

www.yoursite.com/pagename.php?id=2

$id = $_GET['id'];

//Put Query Here (SELECT * FROM TABLE WHERE ID = $id)

 

i think you need to take a deep breath and explain what you need on your pages.

 

Sorry i couldn't help more.

 

Snooble

 

First sorry for the empty posts I sent... it was a mistake I made in a post and tried to correct it, but it seems it sends an empty post instead of to delete it... I didn't know that.... That was not the meaning of sending empty post or to spam the board.

 

About my case, I do not need someone to write codes for me, but to correct what I done wrong.

I think I mis a part of a code in a script that will send/recall the values of Text_ID[0]=4, Text_ID[1]=8, Text_ID[3]=15, etc...

so I can then use these values in the update querry... SET... where Text_ID= $Text_ID[0]... etc...

I think I may need a kind of loop but I don't how to do it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.