Jump to content

Need assist with a simple PHP function


benma

Recommended Posts

I need help with PHP basic syntax, I'm really new to the language.

I'm trying to fetch data from MySQL, as you can see, 1 table 6 columns and 2 rows.

 

 

    +------+--------+--------+--------+-------+-----+

    | first  |second | third  | fourth | fifth | sixth  |

    +------+--------+--------+--------+-------+-----+

    |  A1  |   B1   |   C1   |   D1   |   E1  |  F1    |

    |  A2  |   B2   |   C2   |   D2   |   E2  |  F2    |

    +------+--------+--------+--------+-------+-----+

 

my php file code 

 

    <?php

define('HOST','irrelevant');

define('USERNAME','irrelevant');

define('PASSWORD','irrelevant');

define('DB','irrelevant');

 

$con = mysqli_connect(HOST,USERNAME,PASSWORD,DB) or die('Unable to connect');

 

    $sql = "select * from orders";

 

    $res = mysqli_query($con,$sql);

 

    //while($row = mysqli_fetch_array($res)){

    //array_push($result,array($row[0],$row[1],$row[2],$row[3],$row[4],$row[5]));

    //}

 

    mysqli_close($con);

 

    ?>

 

 

 

All I need here is this output which is 1 array with a count(array)=2 :P

 

{A1 <br> B1 <br> C1 <br> D1 <br> E1 <br> F1 , A2 <br> B2 <br> C2 <br> D2 <br> E2 <br> F2}

 

without the <'br'> command between them all it should look like this

 

{A1 <br'> B1 <br'> C1 <br'> D1 <br'> E1 <br'> F1 , A2 <br'> B2 <br'> C2 <br'> D2 <br'> E2 <br'> F2}

 

in other words, I need it to turn into an array that has just 2 strings in it (the number of rows that currently exist in the table).

 

 

 

This is probably very easy to someone who knows php good, if id'e need to implement this in java it would take me a minute but, damn this php and all these dollars! 

 

thanks in advance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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