Jump to content

lee1963

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by lee1963

  1. firstly thx for response , your right i do have a tendancy to overly complicate things think its because im still new to this. but slowly getting the hang of it. could you give me some snippet of code that will help me with javascript side. think then i can get on , thx in advance
  2. help required for noobie(no hair left) all i want to be able to do is use the individual elements of the array in javascript eg companyname or companyimage but just getting my head in my hand. mysql_select_db("herefordinfo") or die(mysql_error()); echo "Connected to Database"; $dbQuery = 'SELECT * FROM companies'; $dbResult = mysql_query($dbQuery) or die ("Could not read data because " . mysql_error()); $RowCount = mysql_numrows($dbResult); while ($pubs = mysql_fetch_assoc($dbResult)) { $array[] = "{ {$pubs['id']}, {$pubs['companyname']}, {$pubs['companyinfo']}, {$pubs['companyimage']} }"; } echo 'var pub = [' . implode(', ', $array) . '];'; // this ?> <html> <head> <script type="text/javascript"> var jsArray = <?php echo json_encode($array); ?>; document.write(jsArray); //this </script> </head> <boby></body> </html> both php and javescritp output the results below { 1, lichfield vaults, 10 church street hereford , lich.jpg },{ 2, Black Lion, bridge street, blacklion.jpg },{ 3, Saracens Head, st martins street, saracens.jpg }
×
×
  • 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.