View Full Version : Call mysql straight after another one

03-14-2007, 06:30 PM
Hi guys

Could someone please help me.
Basically what I want ive tried to is firstly store values from my database into . Then create buttons corresponding to the amount of rows in the DB. These buttons will then copy the value from $OneLevel and $OneCode and paste them into the two textfields called encodedL and encodedP.

The problem is, is once the buttons are pressed instead of copy and pasting the values from $OneLevel and $OneCode it instead pastes '$OneLevel' and '$OneCode'.

Any suggestions would be great!! :)


@mysql_select_db($database) or die( "Unable to select database");

$query1="SELECT * FROM code WHERE Type='One'";


while ($i < $num_rows) {

print "\t <input type=\"button\" onClick=\"document.getElementById('encodedL').value='$"."$Type"."Level'; document.getElementById('encodedP').value='$"."$Type"."Code'; decode() \" name=\"$Type\" value=\"$Type\" /> \n";




03-14-2007, 06:50 PM
Um... er... any reason you're not just using an array with mysql_fetch_array()?

while ($i < $num_rows) {
$Type = mysql_fetch_array($result);

print "\t <input type=\"button\" onClick=\"document.getElementById('encodedL').value='{$Type['Level']}'; document.getElementById('encodedP').value='{$Type['Code']}'; decode() \" name=\"{$Type['Type']}\" value=\"{$Type['Type']}\" /> \n";



03-14-2007, 07:02 PM
Awesome!!:thumbsup: Oh, I didnt know you could do that...I just started using mysql the other day.

Anyway thanks for the quick response, it works great!!

Thanks mate. :)