...

View Full Version : Call mysql straight after another one



vorl
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!! :)
Thanks:thumbsup:



<?php
$username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query1="SELECT * FROM code WHERE Type='One'";
$result1=mysql_query($query1);
$OneLevel=mysql_result($result1,$i,"Level");
$OneCode=mysql_result($result1,$i,"Code");

?>

<?
$i=0;
while ($i < $num_rows) {
$Type=mysql_result($result,$i,"Type");


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

$i++;

}

?>

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



$i=0;
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";

$i++;

}

vorl
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. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum