Jump to content

mclard

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mclard's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If i use $i = 1; if ($i<=100) { $SQL = "SELECT * FROM ws WHERE location ='$data' and position ='$i'"; $result = mysql_query($SQL); while ($row=mysql_fetch_array($result)) { if ($row[4] == '$i') { echo "<div><ul id='$i'><li id='$row[0]'>$row[4]</li></ul></div>"; } else { echo "<div><ul id='$i'></ul></div>"; } } $i++; } I get some output but not the right one... What i get in the page source is <div><ul id='1'></ul></div> <div><ul id='1'></ul></div> And what id hope to get is <div><ul id='1'><li></li></ul></div> <div><ul id='2'><li>2</li></ul></div> <div><ul id='3'><li></li></ul></div> <div><ul id='4'><li>4</li></ul></div> Thanks
  2. Just a blank screen...
  3. Hi, I have a mysql database containing 100 records, some of these records have a 'position' against them. Im trying to get the following result.... 1. A list containing 100 entries. 2. If li 1 has a 'position' against it, data is entered from the database, or it has default text, this is to carry on to li 100. What ive got so far follows $i = 1; if ($i<=100) { $SQL = "SELECT * FROM ws WHERE location ='$data' AND position ='$i'"; $result = mysql_query($SQL); while ($row=mysql_fetch_array($result)) { echo "<div><ul id='$i'>"; echo "<li id='$row[0]'>$row[4]</li>"; echo "</ul></div>"; } $i++; } else { echo "????"; } Thanks
  4. Hi, Could anyone tell me the most efficient way to output data from a mysql database into a table in php so as i could output data so as after say 10 entries it starts a new table row. Ive managed to fudge it in the past but having numerous if statements within a whill statement seemed a bit clumsy if $row == 10 { echo "</tr><tr>"; $row++ } elseif $row ==20 etc.etc.etc Thanks
  5. Hi Im trying to import the contents of a flat text file into a mysql database, what ive got so far kind of works but it only enters the first line. The more i look at it it looks like mysql syntax but im at a loss of what to do. Can anyone offer any advice. FLAT FILE FORMAT... entry1 entry2 entry3 [code] $dbname="project"; $dbc = @mysql_connect ('localhost', 'root', '') or die (mysql_error()); @mysql_select_db("$dbname"); $SQL = "LOAD DATA LOCAL INFILE 'path to file' INTO TABLE `user` FIELDS TERMINATED BY ' ' ENCLOSED BY '' ESCAPED BY ' ' LINES TERMINATED BY '\r\n'"; $result = mysql_query($SQL); [/code]
  6. Hi Im trying to get my code to list values from a mysql datatbase and for each item have a clickable button which points to a script to remove the item. So far ive got the following but it only ever passes the last item in the array to the delete script. Dunno if this is a long way round what im trying to do but hope someone can help. Code follows: [CODE] $dbname="project"; $dbc = @mysql_connect ('localhost', 'root', '') or die (mysql_error()); @mysql_select_db("$dbname"); $query = "SELECT * FROM filterurl"; //run the query and handle the results $result = @mysql_query($query, $dbc); echo "<form method=post action='remove.php'><table>";   while($row=mysql_fetch_array($result)) {   echo "<tr><td>$row[1]</td><td><input type='submit' value='REMOVE'><input type='hidden' name='rmurl' value='$row'></tr>";   } echo "</table></form>";  [/CODE] Remove script [CODE] $rmurl = $_POST['rmurl']; echo $rmurl; $dbname="project"; $dbc = @mysql_connect ('localhost', 'root', '') or die (mysql_error()); @mysql_select_db("$dbname"); $SQL = "DELETE FROM filterurl WHERE url = $rmurl"; $result = mysql_query($SQL); header("Location: filterdisplay.php"); [/CODE]
  7. are you hosting the webserver locally?
×
×
  • 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.