SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    spaceing in echo data

    Hello everybody,

    I am new to php and am having a basic problem.

    I need to display data from mysql. I can see the data as i use kevin yanks example but I see the columns attached and need to give spacing between them. I have tried   in echo and have tried using echo in a table but still cannot see the data it is either giving me parse error or error on line 77 which does not exsist.

    while ( $row = mysql_fetch_array($result) ) {
    echo .$row['Lptype']. $row['Larea']. '</p>');
    }

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <? do { ?>
    <tr>
    <td>"<? echo $row['$Lptype']; ?>"</td>
    <td>"<? echo $row['$Lbedrooms'];?>"</td>
    <td>"<? echo $row['$Larea']; ?>"</td>
    <td><a href="edit.php?id=<? echo $data_row['id']; ?>">edit</a> / delete</td>
    </tr>
    </table>

    still cannot see the data.
    Please help
    Thank you

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    while ( $row = mysql_fetch_array($result) ) {
    echo .$row['Lptype']. $row['Larea']. '</p>');
    }

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <? do { ?>
    <tr>
    <td>"<? echo $row['$Lptype']; ?>"</td>
    <td>"<? echo $row['$Lbedrooms'];?>"</td>
    <td>"<? echo $row['$Larea']; ?>"</td>
    <td><a href="edit.php?id=<? echo $data_row['id']; ?>">edit</a> / delete</td>
    </tr>
    </table>
    One thing is that the ?> tag is missing

    PHP Code:

    while ( $row = mysql_fetch_array($result) ) {
    echo .$row['Lptype']. $row['Larea']. '</p>');
    }
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <? do { ?>
    <tr>
    <td>"<? echo $row['$Lptype']; ?>"</td>
    <td>"<? echo $row['$Lbedrooms'];?>"</td>
    <td>"<? echo $row['$Larea']; ?>"</td>
    <td><a href="edit.php?id=<? echo $data_row['id']; ?>">edit</a> / delete</td>
    </tr>
    </table>

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo $row[1] ."&nbsp;"$row[2]; 
    cheers

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    London
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Mark & Reminder your help is appreciated. I could give spacing.

    I have another problem. My problem is I need to insert values into mysql database,which are displayed by functions written in a file stuff.php which is in admin folder. I am pasting the functions written.

    admin/stuff.php

    function show_areas($current_area = "") {
    echo "<select name=\"area\">";
    foreach ($GLOBALS["hounslow_areas"] as $area) {
    echo "<option value=\"$area\" ";
    if ($area == $current_area) echo "selected";
    echo ">".ucfirst($area)."</option>";
    }
    foreach ($GLOBALS["bethnal_green_areas"] as $area) {
    echo "<option value=\"$area\" ";
    if ($area == $current_area) echo "selected";
    echo ">".ucfirst($area)."</option>";
    }
    foreach ($GLOBALS["manor_park_areas"] as $area) {
    echo "<option value=\"$area\" ";
    if ($area == $current_area) echo "selected";
    echo ">".ucfirst($area)."</option>";
    }
    foreach ($GLOBALS["tottenham_areas"] as $area) {
    echo "<option value=\"$area\" ";
    if ($area == $current_area) echo "selected";
    echo ">".ucfirst($area)."</option>";
    }
    echo "<option value=\"other\">Other</option>";
    echo "</select>";
    } // function show_areas()

    function show_bedrooms($no_rooms = "") {
    echo "<select name=\"bedrooms\">";
    for ($i = 1; $i <= 9; $i++) {
    echo "<option value=\"$i\"";
    if ($no_rooms == $i) echo " selected";
    echo ">$i</option>";

    function show_property_type($property_type = "") {
    ?>
    <script language="JavaScript" type="text/JavaScript">
    <!--



    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    //-->
    </script>

    <body>
    <select name="property_type"><option value="house" <?php if ($property_type == "house") echo "selected"; ?>>House</option><option value="bungalow" <?php if ($property_type == "bungalow") echo "selected"; ?>>Bungalow</option><option value="flat" <?php if ($property_type == "flat") echo "selected"; ?>>Flat</option><option value="room" <?php if ($property_type == "room") echo "selected"; ?>>Room</option><option value="studio" <?php if ($property_type == "studio") echo "selected"; ?>>Studio</option><option value="commercial" <?php if ($property_type == "commercial") echo "selected"; ?>>Commercial</option></select>
    <?php
    } // function show_property_type()

    The next code bit is where these functions are used to display data. I need to get the values and insert them in mysql database.

    If it is possible by using the attribute name how do I do it.

    Thank You

    <form action="<?php echo $PHP_SELF; ?>" method="post">
    <input type="hidden" name="submitted" value="validated" />
    <table width="600" align="center">
    <?php if (($submitted == "validated") && empty($name)) echo "<tr><td width=\"600\" colspan=\"2\"><p class=\"error\">You must enter your name</p></td></tr>"; ?>
    <tr>
    <td width="200"><p class="inputdesc">Name/p></td>
    <td width="400"><input type="text" name="name" value="<?php echo $name; ?>" size="30" /></td>
    </tr>
    <?php if (($submitted == "validated") && empty($contact_no)) echo "<tr><td width=\"600\" colspan=\"2\"><p class=\"error\">You must enter a contact number</p></td></tr>"; ?>
    <tr>
    <td width="200"><p class="inputdesc">Contact no/p></td>
    <td width="400"><input type="text" name="contact_no" value="<?php echo $contact_no; ?>" size="30" /></td>
    </tr>
    <?php if (($submitted == "validated") && (!empty($name) && !valid_email($email_address))) echo "<tr><td width=\"600\" colspan=\"2\"><p class=\"error\">The email address you provided is not valid</p></td></tr>"; ?>
    <tr>
    <td width="200"><p class="inputdesc">Email address/p></td>
    <td width="400"><input type="text" name="email_address" value="<?php echo $email_address; ?>" size="30" /></td>
    </tr>
    <tr>
    <td width="200"><p class="inputdesc">Property type/p></td>
    <td width="400"><?php show_property_type(); ?></td>
    </tr>
    <tr>
    <td width="200"><p class="inputdesc">Bedrooms/p></td>
    <td width="400"><?php show_bedrooms(); ?></td>
    </tr>
    <tr>
    <td width="200"><p class="inputdesc">Is the property currently vacant?/p></td>
    <td width="400"><select name="currently_vacant"><option value="yes">Yes</option><option value="no">No</option></select></td>
    </tr>
    <tr>
    <td width="200"><p class="inputdesc">Area/p></td>
    <td width="400"><?php show_areas(); ?></td>
    </tr>
    <tr>
    <td width="200"><p class="inputdesc">Accept DHSS?</p></td>
    <td width="400"><select name="accept_dhss"><option value="yes">Yes</option><option value="no">No</option><option value="dont_mind">Don't mind</option></select></td>
    </tr>
    <tr>
    <td width="200"><p class="inputdesc">Landlord requests/p></td>
    <td width="400"><textarea name="landlord_request" rows="4" cols="35"><?php echo $landlord_request; ?></textarea></td>
    </tr>
    <tr>
    <td width="600" colspan="2" align="center"><input type="submit" name="submit" value="Send" /></td>
    </tr>
    </table>
    </form>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •