3 Replies - 654 Views - Last Post: 06 February 2013 - 08:27 PM Rate Topic: -----

#1 cheabred  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-February 13

PHP auto generating SQL statement.

Posted 06 February 2013 - 06:29 PM

I am working on a website that will be for a database, and managing it, through PHP and SQL, I am trying to make it pull down all the column names and place them in the statement, and also get all the $_POST[] data from the textarea's that are named correctly. and it will not work, I'm not sure if I am doing it correctly, this is the first time I have tried to do something like this.


$string = mysql_query("SELECT * FROM ".$_SESSION['username']."");
	
$sql = "INSERT INTO ".$_SESSION['username']." ('". 
for($j=0; $j < mysql_num_fields($string); $j++) {
	$string1 .= mysql_field_name($string, $j)."', '".; 
}
."') VALUES ('".
for($j=0; $j < mysql_num_fields($string); $j++) {
	$_POST[mysql_field_name($string, $j)]."', '". 
}
"')";
	



Is This A Good Question/Topic? 0
  • +

Replies To: PHP auto generating SQL statement.

#2 cheabred  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-February 13

Re: PHP auto generating SQL statement.

Posted 06 February 2013 - 07:15 PM

never mind, figured it out, you can delete this post now.
Was This Post Helpful? 0
  • +
  • -

#3 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 876
  • View blog
  • Posts: 2,312
  • Joined: 28-March 11

Re: PHP auto generating SQL statement.

Posted 06 February 2013 - 07:21 PM

Posts don't get deleted. I will however move it on over to PHP.
Was This Post Helpful? 0
  • +
  • -

#4 cheabred  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-February 13

Re: PHP auto generating SQL statement.

Posted 06 February 2013 - 08:27 PM

and apparently there is no EDIT feature either.. haha
thank you, im new to the site, and i could not find the PHP section.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1