Jump to content

[SOLVED] Setting a variable using value from database


cleary1981

Recommended Posts

Need help cos my heads to sore to think. lol

 

I want to set the height and width value from a database

 

function generate_module() {
//when generate button is pressed

var h="50"; var w="50";

document.getElementById("object").src="box.gif";
document.getElementById("object").border=1;
document.getElementById("object").height=h;
document.getElementById("object").width=w;
}
</script>

<?php
$query = mysql_query("SELECT * FROM table WHERE whatever = 'whatever'");
$row = mysql_fetch_assoc($query);

$height = $row['height'];
$width = $row['width'];
?>

function generate_module() {
//when generate button is pressed

var h="<?=$height;?>"; var w="<?=$width;?>";

document.getElementById("object").src="box.gif";
document.getElementById("object").border=1;
document.getElementById("object").height=h;
document.getElementById("object").width=w;
}
</script>

 

something along those lines...

 

needing help with PHP because your head hurts isn't a very sympathetic excuse.

 

ACE

Archived

This topic is now archived and is closed to further replies.

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